<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	>

<channel>
	<title>zedia flash blog &#187; otf</title>
	<atom:link href="http://www.zedia.net/tag/otf/feed/" rel="self" type="application/rss+xml" />
	<link>http://www.zedia.net</link>
	<description>Flash, ActionScript, SEO and everything in between</description>
	<lastBuildDate>Wed, 21 Jul 2010 17:07:49 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.0</generator>
		<item>
		<title>Fonts are my bane; not anymore!</title>
		<link>http://www.zedia.net/2010/fonts-are-my-bane-not-anymore/</link>
		<comments>http://www.zedia.net/2010/fonts-are-my-bane-not-anymore/#comments</comments>
		<pubDate>Thu, 14 Jan 2010 15:15:07 +0000</pubDate>
		<dc:creator>zedia.net</dc:creator>
				<category><![CDATA[ActionScript 3]]></category>
		<category><![CDATA[AS3]]></category>
		<category><![CDATA[Embed]]></category>
		<category><![CDATA[Flex]]></category>
		<category><![CDATA[Fonts]]></category>
		<category><![CDATA[otf]]></category>
		<category><![CDATA[pfb]]></category>
		<category><![CDATA[ttf]]></category>
		<category><![CDATA[underline]]></category>

		<guid isPermaLink="false">http://www.zedia.net/?p=521</guid>
		<description><![CDATA[I hate managing fonts in Flash, I truly hate it. I don&#8217;t understand why it is not easier than this after all that time. How about underline; why can&#8217;t we still underline in the Flash IDE? That shouldn&#8217;t be voodoo magic, even Notepad has underline, ok, Notepad doesn&#8217;t have the underlining functionality, but Wordpad does. [...]]]></description>
			<content:encoded><![CDATA[<p>I hate managing fonts in Flash, I truly hate it. I don&#8217;t understand why it is not easier than this after all that time. How about underline; why can&#8217;t we still underline in the Flash IDE? That shouldn&#8217;t be voodoo magic, even Notepad has underline, ok, Notepad doesn&#8217;t have the underlining functionality, but Wordpad does.</p>
<p>Anyway, my biggest problem with fonts and Flash is not the underlining problem, but when you start using static and dynamic textfields with the same font family but with different font style. When you do that, your dynamic textfields will just not show and that is really annoying. A solution that works is if you put all textfields dynamic, but that&#8217;s even more annoying.</p>
<p>Now a really cool feature is that you can now embed fonts using the embed tag just like this:</p>

<div class="wp_syntax"><div class="code"><pre class="actionscript" style="font-family:monospace;"><span style="color: #66cc66;">&#91;</span>Embed<span style="color: #66cc66;">&#40;</span>source=<span style="color: #ff0000;">&quot;assets/fonts/GNL_____.PFB&quot;</span>, fontName =<span style="color: #ff0000;">&quot;zedia GillSansLight&quot;</span>, unicodeRange=<span style="color: #ff0000;">'U+0020-U+007A, U+00C0-U+00F6, U+2019'</span>, mimeType=<span style="color: #ff0000;">&quot;application/x-font-truetype&quot;</span><span style="color: #66cc66;">&#41;</span><span style="color: #66cc66;">&#93;</span>
<span style="color: #0066CC;">private</span> <span style="color: #000000; font-weight: bold;">var</span> GillSansLight2:<span style="color: #000000; font-weight: bold;">Class</span>;</pre></div></div>

<p>Not sure that this will work when you compile using the Flash IDE, but when doing ActionScript projects or Flex projects this works just fine. This way you can embed ttf, otf and pfb fonts. I am not quite sure how to embed fonts on a Mac system, it will still work with those formats, but I know Macintosh has other formats. The thing that makes this work is that you can specify the font name. Be sure to specify a name that you know Flash wouldn&#8217;t specify. My coworker gave me the trick to add the name of the project in the font name that way it&#8217;s always going to be different than Flash. If you don&#8217;t make it different you will still run in the problem of your dynamic textfields not showing up.</p>
<p>Once you have embedded the font you need to register it in your application like this:</p>

<div class="wp_syntax"><div class="code"><pre class="actionscript" style="font-family:monospace;"><span style="color: #0066CC;">Font</span>.<span style="color: #006600;">registerFont</span><span style="color: #66cc66;">&#40;</span>GillSansLight2<span style="color: #66cc66;">&#41;</span>;</pre></div></div>

<p>This will make the font available anywhere in your application. All you need to do is create a TextFormat with that font and assign that TextFormat to your textfield:</p>

<div class="wp_syntax"><div class="code"><pre class="actionscript" style="font-family:monospace;"><span style="color: #000000; font-weight: bold;">var</span> tf:<span style="color: #0066CC;">TextFormat</span> = <span style="color: #000000; font-weight: bold;">new</span> <span style="color: #0066CC;">TextFormat</span><span style="color: #66cc66;">&#40;</span><span style="color: #ff0000;">&quot;zedia GillSansLight&quot;</span><span style="color: #66cc66;">&#41;</span>;<span style="color: #808080; font-style: italic;">//this is what you put into fontName in the embed tag</span>
myTextfield.<span style="color: #0066CC;">embedFonts</span> = <span style="color: #000000; font-weight: bold;">true</span>; <span style="color: #808080; font-style: italic;">//this line is also important</span>
myTextfield.<span style="color: #006600;">defaultTextFormat</span> = tf; <span style="color: #808080; font-style: italic;">//always assign the default textformat before modifying the text property</span>
myTextfiled.<span style="color: #0066CC;">text</span> = <span style="color: #ff0000;">&quot;lorem ipsum&quot;</span>;</pre></div></div>

<p>Now, using this technique you can choose exactly what character from the font you want to embed. In the previous example the unicodeRange represented those characters:</p>

<div class="wp_syntax"><div class="code"><pre class="actionscript" style="font-family:monospace;">U+0020-U+007A = <span style="color: #0066CC;">SPACE</span><span style="color: #66cc66;">!</span><span style="color: #ff0000;">&quot;#$%&amp;amp;'()*+,-./0123456789:;&amp;lt;=&amp;gt;?@ABCDEFGHIJKLMNOPQRSTUVWXYZ[<span style="color: #000099; font-weight: bold;">\]</span>^_`abcdefghijklmnopqrstuvwxyz
U+00C0-U+00F6 = ÀÁÂÃÄÅÆÇÈÉÊËÌÍÎÏÐÑÒÓÔÕÖ×ØÙÚÛÜÝÞßàáâãäåæçèéêëìíîïðñòóôõö
U+2019 = ’</span></pre></div></div>

<p>This is a pretty safe set, but you can always change it and optimize it.</p>
<p>Here is a good resource to do Unicode conversion:<br />
<a title="Unicode converter" href="http://rishida.net/scripts/uniview/conversion.php" target="_blank">http://rishida.net/scripts/uniview/conversion.php</a></p>
<div id="facebook_like"><iframe src="http://www.facebook.com/plugins/like.php?href=http%3A%2F%2Fwww.zedia.net%2F2010%2Ffonts-are-my-bane-not-anymore%2F&amp;layout=standard&amp;show-faces=false&amp;width=450&amp;action=like&amp;font=arial&amp;colorscheme=light" scrolling="no" frameborder="0" allowTransparency="true" style="border:none; overflow:hidden; width:550px; height:70px;"></iframe></div>]]></content:encoded>
			<wfw:commentRss>http://www.zedia.net/2010/fonts-are-my-bane-not-anymore/feed/</wfw:commentRss>
		<slash:comments>10</slash:comments>
		</item>
	</channel>
</rss>
