{"id":179,"date":"2007-06-06T16:19:40","date_gmt":"2007-06-06T15:19:40","guid":{"rendered":"http:\/\/www.nivas.hr\/blog\/2007\/06\/06\/font-embedding-problems-in-flash-cs3-ide\/"},"modified":"2007-06-07T11:03:34","modified_gmt":"2007-06-07T10:03:34","slug":"font-embedding-problems-in-flash-cs3-ide","status":"publish","type":"post","link":"https:\/\/www.nivas.hr\/blog\/2007\/06\/06\/font-embedding-problems-in-flash-cs3-ide\/","title":{"rendered":"Font embedding problems in Flash CS3 IDE"},"content":{"rendered":"<p>While I was making a comprehensive test of Croatian letter input field issues in Flash Player 9 (<a href=\"http:\/\/www.nivas.hr\/blog\/2007\/06\/06\/flash-player-9-the-neverending-battle-for-croatian-letters-problem-sa-hrvatskim-dijakriticima-u-flash-playeru-9\/\">check it out here<\/a>), I accidentally discovered potential bug, or very strange feature in new Adobe Flash CS3. Embedding fonts in Flex is easy as 1-2-3, doing the same in CS3 IDE is somehow awkward (broken?).<\/p>\n<p>In Flex you would do this (pseudo exemplary code):<br \/>\n[ftf w=&#8221;400&#8243; h=&#8221;150&#8243;][Embed(source=&#8221;C:\\WINDOWS\\Fonts\\myfont.ttf&#8221;, fontFamily=&#8221;myFont&#8221;)]<br \/>\n&#8230;<br \/>\nvar format:TextFormat= new TextFormat();<br \/>\nformat.font= &#8220;myFont&#8221;;<br \/>\nvar myTextField= new TextField();<br \/>\nmyTextField.embedFonts= true;<br \/>\nmyTextField.defaultTextFormat = format;[\/ftf]<br \/>\nYeah, that works fine. Ok, how to do this in CS3 IDE? First, you import your font to library &#8211; select a font, name it somehow.<br \/>\n<img loading=\"lazy\" src=\"http:\/\/www.nivas.hr\/blog\/wp-content\/photos\/font_import.jpg\" width=\"300\" height=\"104\" alt=\"font import\" align=\"center\" \/><br \/>\nSecondly you export it for ActionScript. In theory (as I interpreted Flash help files), you should just use exact font name you entered as format.font property for a TextFormat. In practice &#8211; Flash IDE never renamed your font. In fact, if you selected <i>Bitmap Text<\/i> during the font import, Flash IDE will rename your font suffixing it with &#8216;_8pt_st&#8217; (in case you selected 8px size). So actually instead using your own name inside TextFormat.font property, you should use the original font name.<\/p>\n<p>Here is a screenshot of a debugger so we all can contemplate about this:<br \/>\n<img loading=\"lazy\" src=\"http:\/\/www.nivas.hr\/blog\/wp-content\/photos\/font_embed_problem.jpg\" width=\"292\" height=\"272\" alt=\"font embed problem\" align=\"center\" \/><br \/>\nDebugger shows contents of embeddedFonts array:<br \/>\n<code>var embeddedFonts:Array = Font.enumerateFonts(false);<\/code><\/p>\n<p>So how to embed fonts trough an IDE? There is a hack. :) Assuming that you have a font in your library which you exported with the class name myEmbeddedFont &#8211; instead of using font name in format.font property, you point to the exported library class name (format.font = new myEmbeddedFont().fontName;) like this:<br \/>\n[ftf w=&#8221;400&#8243; h=&#8221;150&#8243;]<br \/>\nvar format:TextFormat= new TextFormat();<br \/>\nformat.font = new myEmbeddedFont().fontName; \/\/ format.font= &#8220;myFont&#8221;;<br \/>\nvar myTextField= new TextField();<br \/>\nmyTextField.embedFonts= true;<br \/>\nmyTextField.defaultTextFormat = format;[\/ftf]<\/p>\n<p>The part that troubles me the most, is not the strange renaming inside the IDE, well it does because it&#8217;s not documented anywhere, but thing that bothers me is the fact that I was unable to display Croatian letters in my old pixel fonts. What am I missing here? Anybody?<\/p>\n<p>Embedded DINMittelschrift HR CZ, Croatian letters show up nicely.<br \/>\n[flash http:\/\/www.nivas.hr\/blog\/wp-content\/uploads\/2007\/06\/dinamicinputembedtest_din.swf w=250 h=110]<\/p>\n<p>Embedded standard 07_55 hr, which should work, but it doesn&#8217;t. :(<br \/>\n[flash http:\/\/www.nivas.hr\/blog\/wp-content\/uploads\/2007\/06\/dinamicinputembedtest_standard.swf w=250 h=110]<\/p>\n","protected":false},"excerpt":{"rendered":"<p>While I was making a comprehensive test of Croatian letter input field issues in Flash Player 9 (check it out here), I accidentally discovered potential bug, or very strange feature in new Adobe Flash CS3. Embedding fonts in Flex is easy as 1-2-3, doing the same in CS3 IDE is somehow awkward (broken?). In Flex&#8230;<\/p>\n","protected":false},"author":3,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":[],"categories":[1,2],"tags":[],"_links":{"self":[{"href":"https:\/\/www.nivas.hr\/blog\/wp-json\/wp\/v2\/posts\/179"}],"collection":[{"href":"https:\/\/www.nivas.hr\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.nivas.hr\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.nivas.hr\/blog\/wp-json\/wp\/v2\/users\/3"}],"replies":[{"embeddable":true,"href":"https:\/\/www.nivas.hr\/blog\/wp-json\/wp\/v2\/comments?post=179"}],"version-history":[{"count":0,"href":"https:\/\/www.nivas.hr\/blog\/wp-json\/wp\/v2\/posts\/179\/revisions"}],"wp:attachment":[{"href":"https:\/\/www.nivas.hr\/blog\/wp-json\/wp\/v2\/media?parent=179"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.nivas.hr\/blog\/wp-json\/wp\/v2\/categories?post=179"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.nivas.hr\/blog\/wp-json\/wp\/v2\/tags?post=179"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}