Re: [Flashcoders] Using an embedded font
Thanks Kerry. Best, Karl On Sep 22, 2010, at 9:27 PM, Kerry Thompson wrote: Juan Pablo Califano wrote: I hear you. The way flash handles fonts is a royal mess. It must be. I went back to an earlier version that hadn't worked, and now it's working. Go figure. I rebooted Windows. Maybe that's all it needed. But IT'S DONE! Yay! Thanks for all the help, guys. If you're interested, here's what I ended up with that works: package { import flash.display.Sprite; import flash.text.AntiAliasType; import flash.text.Font; import flash.text.TextField; import flash.text.TextFieldAutoSize; import flash.text.TextFieldType; import flash.text.TextFormat; import flash.utils.getQualifiedClassName; public class FontEmbedding extends Sprite { public function FontEmbedding() { registerFonts(); showText(); } /** * Embeds the plain Garamond 3 font - letters, numbers and selected unicode characters and punctuation. */ [Embed( source='../fonts/GaramThrSC.ttf', unicodeRange='U+0020-U+007E,U+00D7,U+00F7,U+03B1,U+0096,U+0096,U +2212', fontName='GaramondTheeEmbedded', mimeType='application/x-font', advancedAntiAliasing='true', embedAsCFF='false' )] private static var GaramondTheeEmbedded: Class; private function showText():void { var textFormat:TextFormat; var textField:TextField; textFormat = new TextFormat(); textFormat.color = 0x00; textFormat.font = "GaramondTheeEmbedded"; textField = new TextField(); textField.defaultTextFormat = textFormat; textField.border = (true); textField.embedFonts = true; textField.text = "Hello Client!"; textField.width = 100; textField.height = 30; addChild(textField); textField.x = 100; textField.y = 60; } /** * If you are loading a font from another .swf,this method needs to be called once * after the class library has been loaded into memory. * It registers the embedded fonts and makes them available for styling text in the application. * */ public static function registerFonts(): void { Font.registerFont(GaramondTheeEmbedded); } } } ___ Flashcoders mailing list Flashcoders@chattyfig.figleaf.com http://chattyfig.figleaf.com/mailman/listinfo/flashcoders Karl DeSaulniers Design Drumm http://designdrumm.com ___ Flashcoders mailing list Flashcoders@chattyfig.figleaf.com http://chattyfig.figleaf.com/mailman/listinfo/flashcoders
Re: [Flashcoders] Using an embedded font
Juan Pablo Califano wrote: > I hear you. The way flash handles fonts is a royal mess. It must be. I went back to an earlier version that hadn't worked, and now it's working. Go figure. I rebooted Windows. Maybe that's all it needed. But IT'S DONE! Yay! Thanks for all the help, guys. If you're interested, here's what I ended up with that works: package { import flash.display.Sprite; import flash.text.AntiAliasType; import flash.text.Font; import flash.text.TextField; import flash.text.TextFieldAutoSize; import flash.text.TextFieldType; import flash.text.TextFormat; import flash.utils.getQualifiedClassName; public class FontEmbedding extends Sprite { public function FontEmbedding() { registerFonts(); showText(); } /** * Embeds the plain Garamond 3 font - letters, numbers and selected unicode characters and punctuation. */ [Embed( source='../fonts/GaramThrSC.ttf', unicodeRange='U+0020-U+007E,U+00D7,U+00F7,U+03B1,U+0096,U+0096,U+2212', fontName='GaramondTheeEmbedded', mimeType='application/x-font', advancedAntiAliasing='true', embedAsCFF='false' )] private static var GaramondTheeEmbedded: Class; private function showText():void { var textFormat:TextFormat; var textField:TextField; textFormat = new TextFormat(); textFormat.color = 0x00; textFormat.font = "GaramondTheeEmbedded"; textField = new TextField(); textField.defaultTextFormat = textFormat; textField.border = (true); textField.embedFonts = true; textField.text = "Hello Client!"; textField.width = 100; textField.height = 30; addChild(textField); textField.x = 100; textField.y = 60; } /** * If you are loading a font from another .swf,this method needs to be called once * after the class library has been loaded into memory. * It registers the embedded fonts and makes them available for styling text in the application. * */ public static function registerFonts(): void { Font.registerFont(GaramondTheeEmbedded); } } } ___ Flashcoders mailing list Flashcoders@chattyfig.figleaf.com http://chattyfig.figleaf.com/mailman/listinfo/flashcoders
Re: [Flashcoders] Using an embedded font
PS: If nothing else works and you're in a hurry, maybe this is worth a try. Make a new fla. Place a textfield on the stage and embed the fonts manually in the Flash IDE. Put this text field inside a MovieClip and export it. Publish this fla as a swc, add it to your FB project and somewhere do this to force the compiler to include this mc in your FB swf. var dummy:MyMovieClip; This should force the compiler to include the mc and indirectly the glyphs you have embbeded in your on stage text field. This is rather gross and unelegant and I'm not sure if it'll play nice with text fields created with code, but I generally work with fla's that have text fields with embedded fonts in the Flase IDE and having a dummy textfield is sometimes the easier way to make sure font are embbeded for the whole swf and that all text fields display the fonts correctly. 2010/9/22 Juan Pablo Califano > I hear you. The way flash handles fonts is a royal mess. > > Have you tried this method? > > > http://www.adobe.com/livedocs/flash/9.0/ActionScriptLangRefV3/flash/text/Font.html#enumerateFonts() > > It should give you a list of the fonts that are being embbeded in the SWF > and their names. It'll not fix the problem per se, but maybe it shows you > the name of the font as it's registered. > > > Cheers > Juan Pablo Califano > > 2010/9/22 Kerry Thompson > >> Juan Pablo Califano wrote: >> >> >> > var font:Font = new Garamond3Embedded() as Font; >> > textFormat.font = font.fontName; >> >> Well, I tried that too, and still no luck. Just in case it was a path >> problem, I moved the font into the same folder as my .as file, >> adjusted the source accordingly, and still no luck. >> >> Dang, this shouldn't be this hard. I've used embedded fonts in the >> past, and they've worked. I've just never tried to do it all in one >> demo file. >> >> Cordially, >> >> Kerry Thompson >> ___ >> Flashcoders mailing list >> Flashcoders@chattyfig.figleaf.com >> http://chattyfig.figleaf.com/mailman/listinfo/flashcoders >> > > ___ Flashcoders mailing list Flashcoders@chattyfig.figleaf.com http://chattyfig.figleaf.com/mailman/listinfo/flashcoders
Re: [Flashcoders] Using an embedded font
I hear you. The way flash handles fonts is a royal mess. Have you tried this method? http://www.adobe.com/livedocs/flash/9.0/ActionScriptLangRefV3/flash/text/Font.html#enumerateFonts() It should give you a list of the fonts that are being embbeded in the SWF and their names. It'll not fix the problem per se, but maybe it shows you the name of the font as it's registered. Cheers Juan Pablo Califano 2010/9/22 Kerry Thompson > Juan Pablo Califano wrote: > > > var font:Font = new Garamond3Embedded() as Font; > > textFormat.font = font.fontName; > > Well, I tried that too, and still no luck. Just in case it was a path > problem, I moved the font into the same folder as my .as file, > adjusted the source accordingly, and still no luck. > > Dang, this shouldn't be this hard. I've used embedded fonts in the > past, and they've worked. I've just never tried to do it all in one > demo file. > > Cordially, > > Kerry Thompson > ___ > Flashcoders mailing list > Flashcoders@chattyfig.figleaf.com > http://chattyfig.figleaf.com/mailman/listinfo/flashcoders > ___ Flashcoders mailing list Flashcoders@chattyfig.figleaf.com http://chattyfig.figleaf.com/mailman/listinfo/flashcoders
Re: [Flashcoders] Using an embedded font
Juan Pablo Califano wrote: > var font:Font = new Garamond3Embedded() as Font; > textFormat.font = font.fontName; Well, I tried that too, and still no luck. Just in case it was a path problem, I moved the font into the same folder as my .as file, adjusted the source accordingly, and still no luck. Dang, this shouldn't be this hard. I've used embedded fonts in the past, and they've worked. I've just never tried to do it all in one demo file. Cordially, Kerry Thompson ___ Flashcoders mailing list Flashcoders@chattyfig.figleaf.com http://chattyfig.figleaf.com/mailman/listinfo/flashcoders
Re: [Flashcoders] Using an embedded font
Karl DeSaulniers wrote: > I think Chris's suggestion may be the trick. > I know I had that headache too and placing the format on after the text > loaded did the trick. That looked promising, but I'm getting the same result--I can see the text field outline on screen, but no text. > But I know with embedding the font, mine wouldnt work unless everything was > "Arial" with a cap A cause my font name was Arial.ttf. I'm pretty certain that's not it. Mark Jonkman showed me how to embed a font, and I'm looking at his code (which I know works), and he named a font something like 'SegoeBlackEmbedded', while the file name is just SegoeBlk.ttf. That font shows up in Windows Font Viewer as Segoe Black. > go fig. only other thing I would say is are you declaring the var for the > font name in your class appropriately? > > Best, > Karl > I think that's what Juan Pablo was suggesting. I'll try it and see if it makes a difference. Cordially, Kerry Thompson ___ Flashcoders mailing list Flashcoders@chattyfig.figleaf.com http://chattyfig.figleaf.com/mailman/listinfo/flashcoders
Re: [Flashcoders] Using an embedded font
I think Chris's suggestion may be the trick. I know I had that headache too and placing the format on after the text loaded did the trick. But I know with embedding the font, mine wouldnt work unless everything was "Arial" with a cap A cause my font name was Arial.ttf. go fig. only other thing I would say is are you declaring the var for the font name in your class appropriately? Best, Karl On Sep 22, 2010, at 8:31 PM, Kerry Thompson wrote: Karl DeSaulniers wrote: Correct me if I am wrong, but don't font embed references have to match the names exactly? case sensitive as well? What is on the stage, the font name and library item name? No, I think you're right. I've tried it with the exact same name, with the same results. [Embed( source='../fonts/GaramThrSC.ttf', fontName='Garamond3Embedded' )] Cordially, Kerry Thompson ___ Flashcoders mailing list Flashcoders@chattyfig.figleaf.com http://chattyfig.figleaf.com/mailman/listinfo/flashcoders Karl DeSaulniers Design Drumm http://designdrumm.com ___ Flashcoders mailing list Flashcoders@chattyfig.figleaf.com http://chattyfig.figleaf.com/mailman/listinfo/flashcoders
Re: [Flashcoders] Using an embedded font
Juan Pablo Califano wrote: > Have you tried not setting the font name in the text format object? I think > it defaults to Times or something like that. I haven't tried exactly that, but if I comment out the line textField.embedFonts = true; the text shows up. I believe you're right--Times New Roman or something. > Then, if the text shows up, maybe the problem is in the font identifier. It seems to be registering ok. When I look at it in the debugger, it's a valid object. > You could then / also try this, which should give you the right name for the > font. Ok, I'll give that a try. Thanks. Cordially, Kerry Thompson ___ Flashcoders mailing list Flashcoders@chattyfig.figleaf.com http://chattyfig.figleaf.com/mailman/listinfo/flashcoders
Re: [Flashcoders] Using an embedded font
Karl DeSaulniers wrote: > Correct me if I am wrong, but don't font embed references have to match the > names exactly? > case sensitive as well? What is on the stage, the font name and library item > name? No, I think you're right. I've tried it with the exact same name, with the same results. [Embed( source='../fonts/GaramThrSC.ttf', fontName='Garamond3Embedded' )] Cordially, Kerry Thompson ___ Flashcoders mailing list Flashcoders@chattyfig.figleaf.com http://chattyfig.figleaf.com/mailman/listinfo/flashcoders
Re: [Flashcoders] Using an embedded font
PS: I meant this: var font:Font = new Garamond3Embedded() as Font; textFormat.font = font.fontName; 2010/9/22 Juan Pablo Califano > Have you tried not setting the font name in the text format object? I think > it defaults to Times or something like that. > > Then, if the text shows up, maybe the problem is in the font identifier. > > You could then / also try this, which should give you the right name for > the font. > > var font:Garamond3Embedded = new Garamond3Embedded(); > textFormat.font = font.fontName; > > Cheers > Juan Pablo Califano > > 2010/9/22 Kerry Thompson > > I've been banging my head up against this for 4 hours, and the client >> has to ship tonight. >> >> FlashBuilder 4, Windows 7. >> >> I am just trying to make a little demo of how to embed a font, but >> when I pull together code that has worked before into one simple >> class, it doesn't show the text. It draws the outline of the text >> field, but there is no text. When I comment out one line, >> textField.embedFonts = true, it works, but not with the embedded font. >> >> I've tried different fonts, and can't get any of them to work. Can >> somebody spot what I'm doing wrong? >> >> Cordially, >> Kerry Thompson >> >>public class FontEmbedding extends Sprite >>{ >>public function FontEmbedding() >>{ >>showText(); >>} >> >>/** >> * Embeds the Garamond 3 font >> */ >>[Embed( >>source='../fonts/GaramThrSC.ttf', >>fontName='Garamond3' >>)] >> >>private static var Garamond3Embedded: Class; >> >>private function showText():void >>{ >>var textFormat:TextFormat; >>var textField:TextField; >>registerFonts(); >> >>textFormat = new TextFormat(); >>textFormat.color = 0x00; >>textFormat.font = "Garamond3Embedded"; >>textFormat.align = "left"; >> >>textField = new TextField(); >>textField.defaultTextFormat = textFormat; >>textField.border = (true); >> >>textField.embedFonts = true; >> >>textField.text = "Hello Autovod!"; >>textField.width = 100; >>textField.height = 30; >> >>addChild(textField); >>textField.x = 100; >>textField.y = 60; >>} >> >>public static function registerFonts(): void >>{ >>Font.registerFont(Garamond3Embedded); >>} >>} >> } >> ___ >> Flashcoders mailing list >> Flashcoders@chattyfig.figleaf.com >> http://chattyfig.figleaf.com/mailman/listinfo/flashcoders >> > > ___ Flashcoders mailing list Flashcoders@chattyfig.figleaf.com http://chattyfig.figleaf.com/mailman/listinfo/flashcoders
Re: [Flashcoders] Using an embedded font
Have you tried not setting the font name in the text format object? I think it defaults to Times or something like that. Then, if the text shows up, maybe the problem is in the font identifier. You could then / also try this, which should give you the right name for the font. var font:Garamond3Embedded = new Garamond3Embedded(); textFormat.font = font.fontName; Cheers Juan Pablo Califano 2010/9/22 Kerry Thompson > I've been banging my head up against this for 4 hours, and the client > has to ship tonight. > > FlashBuilder 4, Windows 7. > > I am just trying to make a little demo of how to embed a font, but > when I pull together code that has worked before into one simple > class, it doesn't show the text. It draws the outline of the text > field, but there is no text. When I comment out one line, > textField.embedFonts = true, it works, but not with the embedded font. > > I've tried different fonts, and can't get any of them to work. Can > somebody spot what I'm doing wrong? > > Cordially, > Kerry Thompson > >public class FontEmbedding extends Sprite >{ >public function FontEmbedding() >{ >showText(); >} > >/** > * Embeds the Garamond 3 font > */ >[Embed( >source='../fonts/GaramThrSC.ttf', >fontName='Garamond3' >)] > >private static var Garamond3Embedded: Class; > >private function showText():void >{ >var textFormat:TextFormat; >var textField:TextField; >registerFonts(); > >textFormat = new TextFormat(); >textFormat.color = 0x00; >textFormat.font = "Garamond3Embedded"; >textFormat.align = "left"; > >textField = new TextField(); >textField.defaultTextFormat = textFormat; >textField.border = (true); > >textField.embedFonts = true; > >textField.text = "Hello Autovod!"; >textField.width = 100; >textField.height = 30; > >addChild(textField); >textField.x = 100; >textField.y = 60; >} > >public static function registerFonts(): void >{ >Font.registerFont(Garamond3Embedded); >} >} > } > ___ > Flashcoders mailing list > Flashcoders@chattyfig.figleaf.com > http://chattyfig.figleaf.com/mailman/listinfo/flashcoders > ___ Flashcoders mailing list Flashcoders@chattyfig.figleaf.com http://chattyfig.figleaf.com/mailman/listinfo/flashcoders
Re: [Flashcoders] Using an embedded font
Correct me if I am wrong, but don't font embed references have to match the names exactly? case sensitive as well? What is on the stage, the font name and library item name? Karl On Sep 22, 2010, at 8:05 PM, Kerry Thompson wrote: I've been banging my head up against this for 4 hours, and the client has to ship tonight. FlashBuilder 4, Windows 7. I am just trying to make a little demo of how to embed a font, but when I pull together code that has worked before into one simple class, it doesn't show the text. It draws the outline of the text field, but there is no text. When I comment out one line, textField.embedFonts = true, it works, but not with the embedded font. I've tried different fonts, and can't get any of them to work. Can somebody spot what I'm doing wrong? Cordially, Kerry Thompson public class FontEmbedding extends Sprite { public function FontEmbedding() { showText(); } /** * Embeds the Garamond 3 font */ [Embed( source='../fonts/GaramThrSC.ttf', fontName='Garamond3' )] private static var Garamond3Embedded: Class; private function showText():void { var textFormat:TextFormat; var textField:TextField; registerFonts(); textFormat = new TextFormat(); textFormat.color = 0x00; textFormat.font = "Garamond3Embedded"; textFormat.align = "left"; textField = new TextField(); textField.defaultTextFormat = textFormat; textField.border = (true); textField.embedFonts = true; textField.text = "Hello Autovod!"; textField.width = 100; textField.height = 30; addChild(textField); textField.x = 100; textField.y = 60; } public static function registerFonts(): void { Font.registerFont(Garamond3Embedded); } } } ___ Flashcoders mailing list Flashcoders@chattyfig.figleaf.com http://chattyfig.figleaf.com/mailman/listinfo/flashcoders Karl DeSaulniers Design Drumm http://designdrumm.com ___ Flashcoders mailing list Flashcoders@chattyfig.figleaf.com http://chattyfig.figleaf.com/mailman/listinfo/flashcoders
RE: [Flashcoders] Using an embedded font
Hi Kerry, I think this is one that gave me headaches a while ago... My solution was to apply the textFormat AFTER the text has been applied to the textField. C: -Original Message- From: flashcoders-boun...@chattyfig.figleaf.com [mailto:flashcoders-boun...@chattyfig.figleaf.com] On Behalf Of Kerry Thompson Sent: Thursday, 23 September 2010 11:05 AM To: Flash Coders List Subject: [Flashcoders] Using an embedded font I've been banging my head up against this for 4 hours, and the client has to ship tonight. FlashBuilder 4, Windows 7. I am just trying to make a little demo of how to embed a font, but when I pull together code that has worked before into one simple class, it doesn't show the text. It draws the outline of the text field, but there is no text. When I comment out one line, textField.embedFonts = true, it works, but not with the embedded font. I've tried different fonts, and can't get any of them to work. Can somebody spot what I'm doing wrong? Cordially, Kerry Thompson public class FontEmbedding extends Sprite { public function FontEmbedding() { showText(); } /** * Embeds the Garamond 3 font */ [Embed( source='../fonts/GaramThrSC.ttf', fontName='Garamond3' )] private static var Garamond3Embedded: Class; private function showText():void { var textFormat:TextFormat; var textField:TextField; registerFonts(); textFormat = new TextFormat(); textFormat.color = 0x00; textFormat.font = "Garamond3Embedded"; textFormat.align = "left"; textField = new TextField(); textField.defaultTextFormat = textFormat; textField.border = (true); textField.embedFonts = true; textField.text = "Hello Autovod!"; textField.width = 100; textField.height = 30; addChild(textField); textField.x = 100; textField.y = 60; } public static function registerFonts(): void { Font.registerFont(Garamond3Embedded); } } } ___ Flashcoders mailing list Flashcoders@chattyfig.figleaf.com http://chattyfig.figleaf.com/mailman/listinfo/flashcoders This e-mail, including any attached files, may contain confidential and privileged information for the sole use of the intended recipient. Any review, use, distribution, or disclosure by others is strictly prohibited. If you are not the intended recipient (or authorized to receive information for the intended recipient), please contact the sender by reply e-mail and delete all copies of this message. ___ Flashcoders mailing list Flashcoders@chattyfig.figleaf.com http://chattyfig.figleaf.com/mailman/listinfo/flashcoders