Locked
5
Replies
5
0
Explorer
,
/t5/flex-discussions/embed-font-issue/td-p/773100
Feb 03, 2009
Feb 03, 2009
Copy link to clipboard
Copied
Hi, I seem to have a problem embedding a font in my flash
file. The font is "GE SS Unique Light", its an arabic font. I'm
using Flash, and am using the component instance in the library to
embed the fonts. I'm building an english and chinese version of the
site with exactly the same code, they just reference different XML
files with the content.
I was having trouble with them all not embedding properly and after scouring through the forums, I added - charFormat.fontLookup = FontLookup.EMBEDDED_CFF; which worked immediately for both the Chinese and English sites, but not at all for the Arabic site, in fact the Arabic font broke and displayed the 'box with a cross' - 'no font here... here no font etc etc'...
So, I tried to import the font in a swf as described in the very handy pdf provided named... textlayout_flashcomponent_overview.pdf
Now, that didn't work either, but I noticed than when it traced the embedded fonts it traced,
GE SS Unique Light
as
GE SS Unique Light Light
I did read somewhere about some naming issues with fonts, but then when I renamed the font with the extra 'Light' on the end, that didn't work either... but both version render fine in flash itself...
Also, if I try and trace the embedded fonts in the Chinese (SimSum) and English (Helvetica, Neue LT Com 55 Roman, Adobe Garamond Pro, Helvetica Neue Light) versions, only the english version gets traced... thats not really a problem, but thought it maybe useful...
Also, its not the font, it must be my code as I cant' seem to embed Adobe Arabic correctly either. I've narrowed down the code to these lines here... I must be missing something... It previews fine, I can see it in a browser on my own machine, but not on others...
I was having trouble with them all not embedding properly and after scouring through the forums, I added - charFormat.fontLookup = FontLookup.EMBEDDED_CFF; which worked immediately for both the Chinese and English sites, but not at all for the Arabic site, in fact the Arabic font broke and displayed the 'box with a cross' - 'no font here... here no font etc etc'...
So, I tried to import the font in a swf as described in the very handy pdf provided named... textlayout_flashcomponent_overview.pdf
Now, that didn't work either, but I noticed than when it traced the embedded fonts it traced,
GE SS Unique Light
as
GE SS Unique Light Light
I did read somewhere about some naming issues with fonts, but then when I renamed the font with the extra 'Light' on the end, that didn't work either... but both version render fine in flash itself...
Also, if I try and trace the embedded fonts in the Chinese (SimSum) and English (Helvetica, Neue LT Com 55 Roman, Adobe Garamond Pro, Helvetica Neue Light) versions, only the english version gets traced... thats not really a problem, but thought it maybe useful...
Also, its not the font, it must be my code as I cant' seem to embed Adobe Arabic correctly either. I've narrowed down the code to these lines here... I must be missing something... It previews fine, I can see it in a browser on my own machine, but not on others...
TOPICS
Text layout framework
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting.
Learn more
1 Correct answer

Feb 05, 2009
Feb 05, 2009
djkencloud,
When you specify a unicode range, as you have above, you will get all of the glyphs in that range which the font actually has defined. The upside to this approach is that if you have an editable TextLayout object, the user should be able to type whatever text he wants, and as long as the letters are within the embedded range, your font will have those glyphs. The downside is that your SWF size may be larger than you would like because few users will type all glyphs in the entire rang...
When you specify a unicode range, as you have above, you will get all of the glyphs in that range which the font actually has defined. The upside to this approach is that if you have an editable TextLayout object, the user should be able to type whatever text he wants, and as long as the letters are within the embedded range, your font will have those glyphs. The downside is that your SWF size may be larger than you would like because few users will type all glyphs in the entire rang...

/t5/flex-discussions/embed-font-issue/m-p/773101#M331
Feb 04, 2009
Feb 04, 2009
Copy link to clipboard
Copied
djkencloud,
The problem you're experiencing is that Flash isn't embedding the entire font. It's only embedding some of the glyph ranges, but not all of them.
My best suggestion for you is to use Gumbo to build a SWF file containing the embedded font you need, and load that SWF from your Flash ActionScript. Also, I think you need to call Font.registerFont() for the font in the external SWF. But other than that, you should be able to use it just like any other font.
One of the important things Gumbo lets you do, is specify the specific ranges you need when embedding a Font.
The problem you're experiencing is that Flash isn't embedding the entire font. It's only embedding some of the glyph ranges, but not all of them.
My best suggestion for you is to use Gumbo to build a SWF file containing the embedded font you need, and load that SWF from your Flash ActionScript. Also, I think you need to call Font.registerFont() for the font in the external SWF. But other than that, you should be able to use it just like any other font.
One of the important things Gumbo lets you do, is specify the specific ranges you need when embedding a Font.
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting.
Learn more
Adobe Employee
,
/t5/flex-discussions/embed-font-issue/m-p/773102#M332
Feb 04, 2009
Feb 04, 2009
Copy link to clipboard
Copied
Some more info on using Gumbo for embedding font subsets is
available on our blog:
Embedded
Font Subsetting Using DefineFont4.
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting.
Learn more
djkencloud
AUTHOR
Explorer
,
/t5/flex-discussions/embed-font-issue/m-p/773103#M333
Feb 05, 2009
Feb 05, 2009
Copy link to clipboard
Copied
Thanks for your prompt reply. I'm having a little trouble
embedding the swf via Gumbo and I have some other questions.
I've not really explored Flex as much as I would like, but I've bought a copy this morning and installed Gumbo and that all seems to be working. I'm trying to use the world maps example as my template to import the swf and making this code work.
I've created this little class in my flex project, directly based on WorldClassFontPack.as
package
{
import flash.display.Sprite;
public class FontPack extends Sprite
{
[Embed(source='/Users/kenmacleod/Library/Fonts/GE SS Unique Light_Arabic font.otf', cff='true', fontName='_ArabicFont', unicodeRange='U+0600-U+06FF')]
public static var _ArabicFont:Class;
public function FontPack():void {}
}
}
In my flash I have the following that is in the function that gets called on the loader complete liistener...
var FontLibrary:Class = e.target.applicationDomain.getDefinition("FontPack") as Class;
Font.registerFont(FontLibrary._ArabicFont);
I have 2 questions...
- The unicode range I've employed is the entire range of unicode values that are assigned to arabic text (these values are from http://unicode.org/charts/PDF/U0600.pdf). Can I do this to capture all the text, or do I need to actually embed the specific ranges particular to the font, if so how do I extract those? I can't read arabic so at this stage I just want everything the font has.
- What do I need to put in my mxml file to reference the class above that I've place in my src folder. Do I just put import FontPack between a Script tags. Sorry, I realise this is super basic stuff, but its just not working.
Thanks.
I've not really explored Flex as much as I would like, but I've bought a copy this morning and installed Gumbo and that all seems to be working. I'm trying to use the world maps example as my template to import the swf and making this code work.
I've created this little class in my flex project, directly based on WorldClassFontPack.as
package
{
import flash.display.Sprite;
public class FontPack extends Sprite
{
[Embed(source='/Users/kenmacleod/Library/Fonts/GE SS Unique Light_Arabic font.otf', cff='true', fontName='_ArabicFont', unicodeRange='U+0600-U+06FF')]
public static var _ArabicFont:Class;
public function FontPack():void {}
}
}
In my flash I have the following that is in the function that gets called on the loader complete liistener...
var FontLibrary:Class = e.target.applicationDomain.getDefinition("FontPack") as Class;
Font.registerFont(FontLibrary._ArabicFont);
I have 2 questions...
- The unicode range I've employed is the entire range of unicode values that are assigned to arabic text (these values are from http://unicode.org/charts/PDF/U0600.pdf). Can I do this to capture all the text, or do I need to actually embed the specific ranges particular to the font, if so how do I extract those? I can't read arabic so at this stage I just want everything the font has.
- What do I need to put in my mxml file to reference the class above that I've place in my src folder. Do I just put import FontPack between a Script tags. Sorry, I realise this is super basic stuff, but its just not working.
Thanks.
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting.
Learn more

/t5/flex-discussions/embed-font-issue/m-p/773104#M334
Feb 05, 2009
Feb 05, 2009
Copy link to clipboard
Copied
djkencloud,
When you specify a unicode range, as you have above, you will get all of the glyphs in that range which the font actually has defined. The upside to this approach is that if you have an editable TextLayout object, the user should be able to type whatever text he wants, and as long as the letters are within the embedded range, your font will have those glyphs. The downside is that your SWF size may be larger than you would like because few users will type all glyphs in the entire range. If your text is not editable, you're best bet is to identify the specific unicode values that you typed, and embed those characters. This produces the "tightest" SWF file.
In your mxml, I don't know if it's important, but the example in Brian's link called for the declaration of the _ArabicFont to be a "private const". Since you want it to be accessible from your Flash code, I'd suggest you make it a "public const".
The only other thing that I can see as a possible problem is that you'll have to reference the "fontFamily" character attribute in your TextFlow as "_ArabicFont". You didn't include any of that in your code, so, you may or may not have that set right. Again, just take a close look at Brian's example.
And just for a sanity check, In your Flash file, you might put a trace statement on the font.fontName to make sure it's "_ArabicFont". Something like the code below prints out all the embedded font names:
var fontArray:Array = Font.enumerateFonts(false);
for(var i:int = 0; i<fontArray.length; i++)
trace(fontArray .fontName);
For even more testing, you can also use the hasGlyphs("blah") method to see if the embedded font has the "blah" glyhps you think you embedded.
Hope some of that makes sense and is helpful.
When you specify a unicode range, as you have above, you will get all of the glyphs in that range which the font actually has defined. The upside to this approach is that if you have an editable TextLayout object, the user should be able to type whatever text he wants, and as long as the letters are within the embedded range, your font will have those glyphs. The downside is that your SWF size may be larger than you would like because few users will type all glyphs in the entire range. If your text is not editable, you're best bet is to identify the specific unicode values that you typed, and embed those characters. This produces the "tightest" SWF file.
In your mxml, I don't know if it's important, but the example in Brian's link called for the declaration of the _ArabicFont to be a "private const". Since you want it to be accessible from your Flash code, I'd suggest you make it a "public const".
The only other thing that I can see as a possible problem is that you'll have to reference the "fontFamily" character attribute in your TextFlow as "_ArabicFont". You didn't include any of that in your code, so, you may or may not have that set right. Again, just take a close look at Brian's example.
And just for a sanity check, In your Flash file, you might put a trace statement on the font.fontName to make sure it's "_ArabicFont". Something like the code below prints out all the embedded font names:
var fontArray:Array = Font.enumerateFonts(false);
for(var i:int = 0; i<fontArray.length; i++)
trace(fontArray .fontName);
For even more testing, you can also use the hasGlyphs("blah") method to see if the embedded font has the "blah" glyhps you think you embedded.
Hope some of that makes sense and is helpful.
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting.
Learn more
djkencloud
AUTHOR
Explorer
,
LATEST
/t5/flex-discussions/embed-font-issue/m-p/773105#M335
Feb 05, 2009
Feb 05, 2009
Copy link to clipboard
Copied
Yes, that made a great deal of sense, thanks very much, I've
got it working now... I'm so happy, I want to run, I want to sing
!
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting.
Learn more
