{"id":41,"date":"2008-04-14T20:56:10","date_gmt":"2008-04-14T18:56:10","guid":{"rendered":"http:\/\/blog.ansuz.nl\/?p=41"},"modified":"2010-11-15T12:59:33","modified_gmt":"2010-11-15T10:59:33","slug":"fonts-and-loading-times","status":"publish","type":"post","link":"http:\/\/blog.ansuz.nl\/index.php\/2008\/04\/14\/fonts-and-loading-times\/","title":{"rendered":"Fonts and loading times"},"content":{"rendered":"<p>When embedding fonts there are a couple of things you need to keep in mind.<\/p>\n<ol>\n<li>When will you need them? (i.e. during the loading)<\/li>\n<li>How to embed them? Using the IDE or Flex?<\/li>\n<li>Where will you embed them?<\/li>\n<\/ol>\n<p>Since there is no way to export you library items in another frame than the first in AS3 you need to look for alternatives.<\/p>\n<p>An alternative would be to just accept the increased file size when embedding them in the first frame and showing no information to the user when this is loading.  I have noticed though that a simple Latin-1 font adds about 30 kB. One could reason with the widespread availability of broadband this shouldn&#8217;t be too bad.<\/p>\n<p>The other option is to embed the font in an external file and decide not to use it for the loader. This keeps your file size down and increases initial loading, that way you can show the user sooner what is happening.<\/p>\n<p>Also keep in mind that when you use a standard embed tag with Flex the embedded font will take up more space than when you use the Flash IDE to embed the fonts. You can avoid this though by specifying in the embed tag which characters you want to embed.  A disadvantage of using the embedding with the IDE is that you won&#8217;t know for sure if your embedded fonts work until you have uninstalled them from you machine or test on a machine that doesn&#8217;t have the font.<\/p>\n<p>Embedding in using the IDE goes as follows:<\/p>\n<ol>\n<li>In the library click<\/li>\n<li>..<\/li>\n<\/ol>\n<p>To embed a font in Flex you use the following code:<\/p>\n<div id=\"ig-sh-1\" class=\"syntax_hilite\">\n\n\t\t<div class=\"toolbar\">\n\n\t\t<div class=\"view-different-container\">\n\t\t\t\t\t\t<a href=\"#\" class=\"view-different\">&lt; View <span>plain text<\/span> &gt;<\/a>\n\t\t\t\t\t<\/div>\n\n\t\t<div class=\"language-name\">ActionScript<\/div>\n\n\t\t\n\t\t<br clear=\"both\">\n\n\t<\/div>\n\t\n\t<div class=\"code\">\n\t\t<ol class=\"actionscript\" style=\"font-family:monospace\"><li style=\"font-weight: normal;vertical-align:top\"><div style=\"font: normal normal 1em\/1.2em monospace;margin:0;padding:0;background:none;vertical-align:top\"><span style=\"color: #808080;font-style: italic\">\/\/ embedding fonts using flex<\/span><\/div><\/li>\n<li style=\"font-weight: normal;vertical-align:top\"><div style=\"font: normal normal 1em\/1.2em monospace;margin:0;padding:0;background:none;vertical-align:top\">&nbsp;<\/div><\/li>\n<li style=\"font-weight: normal;vertical-align:top\"><div style=\"font: normal normal 1em\/1.2em monospace;margin:0;padding:0;background:none;vertical-align:top\"><span style=\"color: #808080;font-style: italic\">\/\/ note: leave the unicodeRange part out is you want to embed the entire font.<\/span><\/div><\/li>\n<li style=\"font-weight: normal;vertical-align:top\"><div style=\"font: normal normal 1em\/1.2em monospace;margin:0;padding:0;background:none;vertical-align:top\"><span style=\"color: #66cc66\">&#091;<\/span> Embed<span style=\"color: #66cc66\">&#040;<\/span> source=<span style=\"color: #ff0000\">&quot;Arial.ttf&quot;<\/span>, fontName=<span style=\"color: #ff0000\">&quot;Arial&quot;<\/span>, mimeType=<span style=\"color: #ff0000\">&quot;application\/x-font-truetype&quot;<\/span>, unicodeRange=<span style=\"color: #ff0000\">&quot;&lt;span&gt;&lt;span class=&quot;<\/span>character<span style=\"color: #ff0000\">&quot;&gt;U+0020-U+002F&lt;\/span&gt;&lt;\/span&gt;&quot;<\/span> <span style=\"color: #66cc66\">&#041;<\/span> <span style=\"color: #66cc66\">&#093;<\/span><\/div><\/li>\n<li style=\"font-weight: normal;vertical-align:top\"><div style=\"font: normal normal 1em\/1.2em monospace;margin:0;padding:0;background:none;vertical-align:top\"><span style=\"color: #0066CC\">public<\/span> <span style=\"color: #000000;font-weight: bold\">var<\/span> Arial:<span style=\"color: #000000;font-weight: bold\">Class<\/span>;<\/div><\/li>\n<\/ol>\t<\/div>\n\n<\/div>\n\n<p>Now if you decide to load the font from an external file, you&#8217;ll need to register the freshly loaded font with the Flash player.<\/p>\n<div id=\"ig-sh-2\" class=\"syntax_hilite\">\n\n\t\t<div class=\"toolbar\">\n\n\t\t<div class=\"view-different-container\">\n\t\t\t\t\t\t<a href=\"#\" class=\"view-different\">&lt; View <span>plain text<\/span> &gt;<\/a>\n\t\t\t\t\t<\/div>\n\n\t\t<div class=\"language-name\">ActionScript<\/div>\n\n\t\t\n\t\t<br clear=\"both\">\n\n\t<\/div>\n\t\n\t<div class=\"code\">\n\t\t<ol class=\"actionscript\" style=\"font-family:monospace\"><li style=\"font-weight: normal;vertical-align:top\"><div style=\"font: normal normal 1em\/1.2em monospace;margin:0;padding:0;background:none;vertical-align:top\"><span style=\"color: #808080;font-style: italic\">\/\/ register the font with the player<\/span><\/div><\/li>\n<li style=\"font-weight: normal;vertical-align:top\"><div style=\"font: normal normal 1em\/1.2em monospace;margin:0;padding:0;background:none;vertical-align:top\"><span style=\"color: #808080;font-style: italic\">\/\/ where appDomain is a reference to the application domain the externally loaded font is in<\/span><\/div><\/li>\n<li style=\"font-weight: normal;vertical-align:top\"><div style=\"font: normal normal 1em\/1.2em monospace;margin:0;padding:0;background:none;vertical-align:top\"><span style=\"color: #000000;font-weight: bold\">var<\/span> arial:<span style=\"color: #000000;font-weight: bold\">Class<\/span> = <span style=\"color: #000000;font-weight: bold\">Class<\/span><span style=\"color: #66cc66\">&#040;<\/span>appDomain.<span style=\"color: #006600\">getDefinition<\/span><span style=\"color: #66cc66\">&#040;<\/span> <span style=\"color: #ff0000\">&quot;Arial&quot;<\/span> <span style=\"color: #66cc66\">&#041;<\/span><span style=\"color: #66cc66\">&#041;<\/span>;<\/div><\/li>\n<li style=\"font-weight: normal;vertical-align:top\"><div style=\"font: normal normal 1em\/1.2em monospace;margin:0;padding:0;background:none;vertical-align:top\"><span style=\"color: #0066CC\">Font<\/span>.<span style=\"color: #006600\">registerFont<\/span><span style=\"color: #66cc66\">&#040;<\/span>arial<span style=\"color: #66cc66\">&#041;<\/span>;<\/div><\/li>\n<\/ol>\t<\/div>\n\n<\/div>\n\n<p>Some useful links about embedding a subset of a (unicode font):<br \/>\n&#8211; <a href=\"http:\/\/jrgraphix.net\/research\/unicode_blocks.php\" target=\"_blank\">Unicode Character Table<\/a><br \/>\n&#8211; <a href=\"http:\/\/developer.yahoo.com\/flash\/articles\/runtime-fonts-as3.html\" target=\"_blank\">Yahoo on runtime font embedding<\/a><\/p>\n<p>That&#8217;s about it for embedding fonts.<\/p>\n<p><strong>Update:<\/strong><br \/>\nIf embedded fonts aren&#8217;t showing up when compiling with Flex 4, add <strong>embedAsCFF=&#8221;false&#8221;<\/strong> to the embed-tag.<\/p>\n<!-- AddThis Advanced Settings generic via filter on the_content --><!-- AddThis Share Buttons generic via filter on the_content -->","protected":false},"excerpt":{"rendered":"<p>When embedding fonts there are a couple of things you need to keep in mind. When will you need them? (i.e. during the loading) How to embed them? Using the IDE or Flex? Where will you embed them? Since there &hellip; <a href=\"http:\/\/blog.ansuz.nl\/index.php\/2008\/04\/14\/fonts-and-loading-times\/\">Continue reading <span class=\"meta-nav\">&rarr;<\/span><\/a><!-- AddThis Advanced Settings generic via filter on get_the_excerpt --><!-- AddThis Share Buttons generic via filter on get_the_excerpt --><\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[8],"tags":[139,17,16],"class_list":["post-41","post","type-post","status-publish","format-standard","hentry","category-actionscript-30","tag-actionscript-30","tag-embed","tag-fonts"],"_links":{"self":[{"href":"http:\/\/blog.ansuz.nl\/index.php\/wp-json\/wp\/v2\/posts\/41","targetHints":{"allow":["GET"]}}],"collection":[{"href":"http:\/\/blog.ansuz.nl\/index.php\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"http:\/\/blog.ansuz.nl\/index.php\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"http:\/\/blog.ansuz.nl\/index.php\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"http:\/\/blog.ansuz.nl\/index.php\/wp-json\/wp\/v2\/comments?post=41"}],"version-history":[{"count":1,"href":"http:\/\/blog.ansuz.nl\/index.php\/wp-json\/wp\/v2\/posts\/41\/revisions"}],"predecessor-version":[{"id":247,"href":"http:\/\/blog.ansuz.nl\/index.php\/wp-json\/wp\/v2\/posts\/41\/revisions\/247"}],"wp:attachment":[{"href":"http:\/\/blog.ansuz.nl\/index.php\/wp-json\/wp\/v2\/media?parent=41"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"http:\/\/blog.ansuz.nl\/index.php\/wp-json\/wp\/v2\/categories?post=41"},{"taxonomy":"post_tag","embeddable":true,"href":"http:\/\/blog.ansuz.nl\/index.php\/wp-json\/wp\/v2\/tags?post=41"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}