<?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>undefined-type &#187; font</title>
	<atom:link href="http://undefined-type.com/tag/font/feed/" rel="self" type="application/rss+xml" />
	<link>http://undefined-type.com</link>
	<description>Flex,Flash &#38; AIR</description>
	<lastBuildDate>Wed, 18 Nov 2009 09:48:23 +0000</lastBuildDate>
	<generator>http://wordpress.org/?v=2.9.2</generator>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
			<item>
		<title>Runtime Fonts with Unicode Range</title>
		<link>http://undefined-type.com/2009/10/runtime-fonts-with-unicode-range/</link>
		<comments>http://undefined-type.com/2009/10/runtime-fonts-with-unicode-range/#comments</comments>
		<pubDate>Thu, 29 Oct 2009 19:03:33 +0000</pubDate>
		<dc:creator>Bäcker</dc:creator>
				<category><![CDATA[Flash]]></category>
		<category><![CDATA[Flex]]></category>
		<category><![CDATA[dynamic]]></category>
		<category><![CDATA[embed]]></category>
		<category><![CDATA[font]]></category>
		<category><![CDATA[runtime font]]></category>
		<category><![CDATA[unicode]]></category>

		<guid isPermaLink="false">http://undefined-type.com/?p=518</guid>
		<description><![CDATA[For a couple of months ago I publish a post about fonts embed with unicode range. There are ways on how to extract the fonts from Flash files with some de-compiling but for those who found the article interesting but never figured out the unicodeRange bit, well there is a solution.
1.) First look on how [...]]]></description>
			<content:encoded><![CDATA[<p>For a couple of months ago I publish a post about fonts embed with unicode range. There are ways on how to extract the fonts from Flash files with some de-compiling but for those who found the article interesting but never figured out the unicodeRange bit, well there is a solution.</p>
<p>1.) First look on how to setup and use the <a href="http://undefined-type.com/2009/02/runtime-dynamic-fonts-for-cs4-fp9-next-gen/" target="_blank">FontManager</a><br />
2.) Download <a href="http://undefined-type.com/wp-content/uploads/2009/10/UnicodeHexCreator.air">UnicodeHexCreator</a> I created to create the unicodeRange.</p>
<p>The AIR Unicode app is used to create the correct unicode range to optimize the amount of bytes that is needed to be loaded. To get the range it&#8217;s really simple.</p>
<p>1.) Copy/Paste your entire XML file to the input field (top field)<br />
2.) Select font to use and set class name.<br />
3.) Press convert<br />
4.) Copy/Paste the unicodeRange to the Flex Project that creates the font file.</p>
<p>Download <a href="http://undefined-type.com/wp-content/uploads/2009/10/UnicodeHexCreator.air">UnicodeHexCreator</a>.</p>
]]></content:encoded>
			<wfw:commentRss>http://undefined-type.com/2009/10/runtime-fonts-with-unicode-range/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>Runtime Dynamic Fonts for CS4 (fp9), next-gen</title>
		<link>http://undefined-type.com/2009/02/runtime-dynamic-fonts-for-cs4-fp9-next-gen/</link>
		<comments>http://undefined-type.com/2009/02/runtime-dynamic-fonts-for-cs4-fp9-next-gen/#comments</comments>
		<pubDate>Fri, 13 Feb 2009 13:35:04 +0000</pubDate>
		<dc:creator>Bäcker</dc:creator>
				<category><![CDATA[Flash]]></category>
		<category><![CDATA[Flex]]></category>
		<category><![CDATA[cs4]]></category>
		<category><![CDATA[dynamic]]></category>
		<category><![CDATA[font]]></category>
		<category><![CDATA[runtime]]></category>
		<category><![CDATA[sharing]]></category>

		<guid isPermaLink="false">http://undefined-type.com/?p=440</guid>
		<description><![CDATA[Runtime Fonts for Flash is a wonderful way when building apps, even better if you are as me and creating international apps for a lot of countries, you have the language supports and the problem with characters in fonts when staring to look at Greek, Japanese, Korea, Chinese and so on.  I have a [...]]]></description>
			<content:encoded><![CDATA[<p>Runtime Fonts for Flash is a wonderful way when building apps, even better if you are as me and creating international apps for a lot of countries, you have the language supports and the problem with characters in fonts when staring to look at Greek, Japanese, Korea, Chinese and so on.  I have a old <a href="http://undefined-type.com/2008/01/runtime-dynamic-fonts-flash-cs3/">Runtime font for CS3</a> that works pretty well. But when starting to use CS4 I wanted to improve the loading and sharing. </p>
<p>So the idea was to use Flex to compile Font SWF files, a big problem when I use Flash CS4 (fp9) and Flex 3. Flex will not recognize my font SWF file, it will also not recognize my local fonts to embed bold/italic font sets. Using an exported CS3 (fp9) file it works just fine.<br />
Note; fp9 = Flash Player 9.</p>
<p>So lets look of how to do this.<br />
First we need to create our font file.<br />
1.) Create an Flex ActionScript project (I use framework 3.2)<br />
2.) The Class name will be something that we will get later so I renamed my as file to FontHolder.as<br />
3.) Remove the constructor and add the embed tags, example below. Note the unicodeRange tag, these are used to select characters to be embedded, remove to embed the entire font.</p>

<div class="wp_syntax"><div class="code"><pre class="actionscript" style="font-family:monospace;">package <span style="color: #66cc66;">&#123;</span>
	<span style="color: #0066CC;">import</span> flash.<span style="color: #006600;">display</span>.<span style="color: #006600;">Sprite</span>;
&nbsp;
	<span style="color: #0066CC;">public</span> <span style="color: #000000; font-weight: bold;">class</span> FontHolder <span style="color: #0066CC;">extends</span> Sprite
	<span style="color: #66cc66;">&#123;</span>
		<span style="color: #66cc66;">&#91;</span>Embed<span style="color: #66cc66;">&#40;</span>systemFont=<span style="color: #ff0000;">'Verdana'</span>, fontFamily=<span style="color: #ff0000;">'Verdana'</span>, mimeType=<span style="color: #ff0000;">'application/x-font'</span>, unicodeRange=<span style="color: #ff0000;">'U+0061-U+0074'</span><span style="color: #66cc66;">&#41;</span><span style="color: #66cc66;">&#93;</span>
		<span style="color: #0066CC;">public</span> <span style="color: #0066CC;">static</span> const verdana_regular:<span style="color: #000000; font-weight: bold;">Class</span>;
&nbsp;
		<span style="color: #66cc66;">&#91;</span>Embed<span style="color: #66cc66;">&#40;</span>systemFont=<span style="color: #ff0000;">'Verdana'</span>, fontFamily=<span style="color: #ff0000;">'Verdana'</span>, mimeType=<span style="color: #ff0000;">'application/x-font'</span>, fontWeight=<span style="color: #ff0000;">'bold'</span>, unicodeRange=<span style="color: #ff0000;">'U+0061-U+0074'</span><span style="color: #66cc66;">&#41;</span><span style="color: #66cc66;">&#93;</span>
		<span style="color: #0066CC;">public</span> <span style="color: #0066CC;">static</span> const verdana_bold:<span style="color: #000000; font-weight: bold;">Class</span>;
	<span style="color: #66cc66;">&#125;</span>
<span style="color: #66cc66;">&#125;</span></pre></div></div>

<p>4.) Now you have your font SWF file to use for the project.</p>
<p>So with your font file it&#8217;s time to use it in the project. In this example I use my <a href="http://undefined-type.com/2008/07/122/">Flex 3 as CS3 development tool.</a>, this is because I create Flash Player 9 project. You can of course use only Flash IDE or any other kind of code editor.<br />
1.) Create a new ActionScript project, change the SDK to CS3.<br />
2.) Click next, &#8220;Main source folder&#8221;, type &#8220;src&#8221;, this is just to put the files more pretty =), Click Finish.<br />
3.) Create a CSS file that will control the fonts. &#8220;default.css&#8221;. Just add two classes that we can work with.</p>

<div class="wp_syntax"><div class="code"><pre class="css" style="font-family:monospace;">h1<span style="color: #00AA00;">&#123;</span>
	<span style="color: #000000; font-weight: bold;">font-family</span><span style="color: #00AA00;">:</span> Verdana<span style="color: #00AA00;">;</span>
	<span style="color: #000000; font-weight: bold;">font-size</span><span style="color: #00AA00;">:</span> <span style="color: #933;">24px</span><span style="color: #00AA00;">;</span>
	<span style="color: #000000; font-weight: bold;">font-weight</span><span style="color: #00AA00;">:</span> <span style="color: #993333;">bold</span><span style="color: #00AA00;">;</span>
<span style="color: #00AA00;">&#125;</span>
body<span style="color: #00AA00;">&#123;</span>
	<span style="color: #000000; font-weight: bold;">font-family</span><span style="color: #00AA00;">:</span> Verdana<span style="color: #00AA00;">;</span>
	<span style="color: #000000; font-weight: bold;">font-size</span><span style="color: #00AA00;">:</span> <span style="color: #933;">12px</span><span style="color: #00AA00;">;</span>
<span style="color: #00AA00;">&#125;</span></pre></div></div>

<p>5.) Download the <a href="http://undefined-type.com/wp-content/uploads/2009/02/fontmanager.swc">FontManager.swc</a> file and add it to your project.</p>
<p>Add SWC <strong>HowTo</strong> for <strong>Flex</strong><br />
6.1.) Create a folder called swc in project folder.<br />
6.2.) Place the FontManager.swc file into the created folder.<br />
6.3.) Right-Click on project folder and select properties<br />
6.4.) In menu choose &#8220;ActionScript Build Path&#8221;, Choose the tab &#8220;Library path&#8221;<br />
6.5.) Click on &#8220;Add SWC Folder&#8221;,  Select the created swc folder and close the windows, all done.</p>
<p>Add SWC <strong>HowTo</strong> for <strong>Flash</strong><br />
7.1.) Create a folder called swc in project folder.<br />
7.2.) Place the FontManager.swc file into the created folder.<br />
7.3.) Open Flash and Publish Settings.<br />
7.4.) Choose the Flash tab and click on Settings next to the script combobox.<br />
7.5.) Choose the &#8220;Library Path&#8221; tab and add the swc file to the list, all done. </p>
<p>So, everything is there. How am I using it? Well, this is a dump on the project playground.<br />
<a href="http://undefined-type.com/wp-content/uploads/2009/02/dynamic_files1.png" rel="lightbox[440]"><img class="alignleft size-full wp-image-454" title="dynamic_files1" src="http://undefined-type.com/wp-content/uploads/2009/02/dynamic_files1.png" alt="dynamic_files1" width="192" height="218" /></a></p>
<p> </p>
<p> </p>
<p> </p>
<p> </p>
<p> </p>
<p> </p>
<p> </p>
<p> </p>
<p>To be able to use the fonts they are needed first to be loaded. By default this is the structure for font swf and css file named default. They can be changed by FontManager.name = &#8216;default&#8217; (the name) and the path with FontManager.path = &#8216;fonts/&#8217;.</p>
<p>The easiest way is to just get the singleton and load it.</p>

<div class="wp_syntax"><div class="code"><pre class="actionscript" style="font-family:monospace;"><span style="color: #000000; font-weight: bold;">var</span> manager:FontManager=FontManager.<span style="color: #006600;">instance</span><span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#41;</span>;
manager.<span style="color: #006600;">addEventListener</span><span style="color: #66cc66;">&#40;</span>Event.<span style="color: #006600;">COMPLETE</span>, onManagerComplete<span style="color: #66cc66;">&#41;</span>;
manager.<span style="color: #006600;">loadStandalone</span><span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#41;</span>;</pre></div></div>

<p>When it&#8217;s loading just send the textfield, style and text to the FontManager, you can add only textfield and text if you want to add e.g. multiple styles to one textfield.<br />
Here&#8217;s some examples.</p>

<div class="wp_syntax"><div class="code"><pre class="actionscript" style="font-family:monospace;"><span style="color: #0066CC;">private</span> <span style="color: #000000; font-weight: bold;">function</span> onManagerComplete<span style="color: #66cc66;">&#40;</span>event:Event<span style="color: #66cc66;">&#41;</span>:<span style="color: #0066CC;">void</span>
<span style="color: #66cc66;">&#123;</span>
	<span style="color: #000000; font-weight: bold;">var</span> tf:<span style="color: #0066CC;">TextField</span> = <span style="color: #000000; font-weight: bold;">new</span> <span style="color: #0066CC;">TextField</span><span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#41;</span>;
	tf.<span style="color: #0066CC;">autoSize</span> = TextFieldAutoSize.<span style="color: #0066CC;">LEFT</span>;
	tf.<span style="color: #0066CC;">border</span> = <span style="color: #000000; font-weight: bold;">true</span>;
	tf.<span style="color: #006600;">rotation</span> = <span style="color: #cc66cc;">6</span>;
	FontManager.<span style="color: #006600;">instance</span><span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#41;</span>.<span style="color: #006600;">register</span><span style="color: #66cc66;">&#40;</span>tf, <span style="color: #ff0000;">&quot;h1&quot;</span>, <span style="color: #ff0000;">&quot;abc&quot;</span><span style="color: #66cc66;">&#41;</span>;
	<span style="color: #0066CC;">this</span>.<span style="color: #006600;">addChild</span><span style="color: #66cc66;">&#40;</span>tf<span style="color: #66cc66;">&#41;</span>;
&nbsp;
	<span style="color: #000000; font-weight: bold;">var</span> tf1:<span style="color: #0066CC;">TextField</span> = <span style="color: #000000; font-weight: bold;">new</span> <span style="color: #0066CC;">TextField</span><span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#41;</span>;
	tf1.<span style="color: #0066CC;">autoSize</span> = TextFieldAutoSize.<span style="color: #0066CC;">LEFT</span>;
	tf1.<span style="color: #006600;">x</span> = <span style="color: #cc66cc;">150</span>;
	tf1.<span style="color: #0066CC;">border</span> = <span style="color: #000000; font-weight: bold;">true</span>;
	tf1.<span style="color: #006600;">rotation</span> = <span style="color: #cc66cc;">6</span>;
	FontManager.<span style="color: #006600;">instance</span><span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#41;</span>.<span style="color: #006600;">register</span><span style="color: #66cc66;">&#40;</span>tf1, <span style="color: #ff0000;">&quot;body&quot;</span>, <span style="color: #ff0000;">&quot;abc&quot;</span><span style="color: #66cc66;">&#41;</span>;
	<span style="color: #0066CC;">this</span>.<span style="color: #006600;">addChild</span><span style="color: #66cc66;">&#40;</span>tf1<span style="color: #66cc66;">&#41;</span>;
&nbsp;
	<span style="color: #000000; font-weight: bold;">var</span> tf2:<span style="color: #0066CC;">TextField</span> = <span style="color: #000000; font-weight: bold;">new</span> <span style="color: #0066CC;">TextField</span><span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#41;</span>;
	tf2.<span style="color: #0066CC;">autoSize</span> = TextFieldAutoSize.<span style="color: #0066CC;">LEFT</span>;
	tf2.<span style="color: #006600;">x</span> = <span style="color: #cc66cc;">300</span>;
	tf2.<span style="color: #0066CC;">border</span> = <span style="color: #000000; font-weight: bold;">true</span>;
	tf2.<span style="color: #006600;">rotation</span> = <span style="color: #cc66cc;">6</span>;
	FontManager.<span style="color: #006600;">instance</span><span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#41;</span>.<span style="color: #0066CC;">text</span><span style="color: #66cc66;">&#40;</span>tf2, <span style="color: #ff0000;">&quot;&lt;h1&gt;abc&lt;/h1&gt;<span style="color: #000099; font-weight: bold;">\n</span>abc&quot;</span><span style="color: #66cc66;">&#41;</span>;
	<span style="color: #0066CC;">this</span>.<span style="color: #006600;">addChild</span><span style="color: #66cc66;">&#40;</span>tf2<span style="color: #66cc66;">&#41;</span>;
<span style="color: #66cc66;">&#125;</span></pre></div></div>

]]></content:encoded>
			<wfw:commentRss>http://undefined-type.com/2009/02/runtime-dynamic-fonts-for-cs4-fp9-next-gen/feed/</wfw:commentRss>
		<slash:comments>3</slash:comments>
		</item>
		<item>
		<title>Runtime Dynamic fonts Flash CS3</title>
		<link>http://undefined-type.com/2008/01/runtime-dynamic-fonts-flash-cs3/</link>
		<comments>http://undefined-type.com/2008/01/runtime-dynamic-fonts-flash-cs3/#comments</comments>
		<pubDate>Mon, 28 Jan 2008 16:37:13 +0000</pubDate>
		<dc:creator>Bäcker</dc:creator>
				<category><![CDATA[Flash]]></category>
		<category><![CDATA[embed]]></category>
		<category><![CDATA[font]]></category>
		<category><![CDATA[runtime font]]></category>

		<guid isPermaLink="false">http://localhost/undefined_type_/?p=61</guid>
		<description><![CDATA[All the examples showing runtime dynamic fonts for flash cs3 includes that you export swf file with a class that contains embedded font [Embed ??my font??].
This doesn’t really works for me because I need specified characters for a lot of different countrys. Usually when developing a flash application I have to handle between 15-50 countrys.

So [...]]]></description>
			<content:encoded><![CDATA[<p>All the examples showing runtime dynamic fonts for flash cs3 includes that you export swf file with a class that contains embedded font [Embed ??my font??].</p>
<p>This doesn’t really works for me because I need specified characters for a lot of different countrys. Usually when developing a flash application I have to handle between 15-50 countrys.</p>
<p><a href="http://undefined-type.com/wp-content/uploads/2008/01/embed01.jpg" rel="lightbox[61]"><img class="alignnone size-full wp-image-300" title="embed01" src="http://undefined-type.com/wp-content/uploads/2008/01/embed01.jpg" alt="embed01" width="310" height="201" /></a></p>
<p>So I made my own little solution, made one of these for flash 6 for a couple of years ago and the trick still works. It basiclly works by loading shared runtime librarys and then embedded fonts will be shared cross the application when using a lot of swf files.</p>
<p>Making it a static class it’s easy to use.</p>

<div class="wp_syntax"><div class="code"><pre class="actionscript" style="font-family:monospace;">CSS.<span style="color: #006600;">loadStyleName</span> = <span style="color: #ff0000;">&quot;default&quot;</span>;CSS.<span style="color: #006600;">loadStylePath</span> = <span style="color: #ff0000;">&quot;css/&quot;</span>;CSS.<span style="color: #006600;">addEventListener</span><span style="color: #66cc66;">&#40;</span>IOErrorEvent.<span style="color: #006600;">IO_ERROR</span>, <span style="color: #0066CC;">this</span>.<span style="color: #006600;">onError</span><span style="color: #66cc66;">&#41;</span>;CSS.<span style="color: #006600;">addEventListener</span><span style="color: #66cc66;">&#40;</span>Event.<span style="color: #006600;">COMPLETE</span>, <span style="color: #0066CC;">this</span>.<span style="color: #006600;">onComplete</span><span style="color: #66cc66;">&#41;</span>;CSS.<span style="color: #006600;">initialize</span><span style="color: #66cc66;">&#40;</span> <span style="color: #0066CC;">this</span> <span style="color: #66cc66;">&#41;</span>;</pre></div></div>

<p>And then to use it on textfields.</p>

<div class="wp_syntax"><div class="code"><pre class="actionscript" style="font-family:monospace;">txtField.<span style="color: #006600;">styleSheet</span> = CSS.<span style="color: #006600;">styleSheet</span>;txtField.<span style="color: #0066CC;">embedFonts</span> = <span style="color: #000000; font-weight: bold;">true</span>;txtField.<span style="color: #0066CC;">htmlText</span> = <span style="color: #ff0000;">&quot;&amp;amp;lt;span class='subTest'&amp;amp;gt;Embed Arial&amp;amp;lt;/span&amp;amp;gt;&quot;</span>;txtField.<span style="color: #006600;">rotation</span> = <span style="color: #cc66cc;">5</span>;
&nbsp;
txtField2.<span style="color: #006600;">styleSheet</span> = CSS.<span style="color: #006600;">styleSheet</span>;txtField2.<span style="color: #0066CC;">embedFonts</span> = <span style="color: #000000; font-weight: bold;">true</span>;txtField2.<span style="color: #0066CC;">htmlText</span> = <span style="color: #ff0000;">&quot;&amp;amp;lt;span class='subTest'&amp;amp;gt;Try embed Arial Black&amp;amp;lt;/span&amp;amp;gt;&quot;</span>;txtField2.<span style="color: #006600;">rotation</span> = -<span style="color: #cc66cc;">5</span>;</pre></div></div>

<p>To make this work.</p>
<p>1.1) Create your shared library file (example: default_lib.fla)</p>
<p>1.2) Create MovieClip on stage and export it for runtime.</p>
<p>1.3) In the MovieClip create a textfield for each font you need, embedd all the characters needed.<br />
<a href="http://undefined-type.com/wp-content/uploads/2008/01/embed02.jpg" rel="lightbox[61]"><img class="alignnone size-medium wp-image-301" title="embed02" src="http://undefined-type.com/wp-content/uploads/2008/01/embed02-300x241.jpg" alt="embed02" width="300" height="241" /></a></p>
<p>2.1) Create your shared library holder file (example: default.fla)</p>
<p>2.2) On the stage add the runtime MovieClip and give it instance name mcFont</p>
<p>3.1) Create your css file (example: default.css)</p>
<p>3.2) Add the styles that your need<br />
<a href="http://undefined-type.com/wp-content/uploads/2008/01/embed03.jpg" rel="lightbox[61]"><img class="alignnone size-full wp-image-302" title="embed03" src="http://undefined-type.com/wp-content/uploads/2008/01/embed03.jpg" alt="embed03" width="292" height="462" /></a></p>
<p>4.1) In the Application file add the following load code (look at example in top)</p>
<p>You can download example files here: <a href="http://undefined-type.com/wp-content/uploads/2008/01/runtimefonts_as3.zip">runtimefonts_as3</a></p>
]]></content:encoded>
			<wfw:commentRss>http://undefined-type.com/2008/01/runtime-dynamic-fonts-flash-cs3/feed/</wfw:commentRss>
		<slash:comments>10</slash:comments>
		</item>
	</channel>
</rss>

