<?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>Flex Examples &#187; unicode range</title>
	<atom:link href="http://blog.flexexamples.com/tag/unicode-range/feed/" rel="self" type="application/rss+xml" />
	<link>http://blog.flexexamples.com</link>
	<description>Just a bunch of Adobe Flex Examples</description>
	<lastBuildDate>Wed, 26 Jan 2011 18:09:51 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
			<item>
		<title>Specifying custom named unicode ranges in Flex</title>
		<link>http://blog.flexexamples.com/2008/01/24/specifying-custom-named-unicode-ranges-in-flex/</link>
		<comments>http://blog.flexexamples.com/2008/01/24/specifying-custom-named-unicode-ranges-in-flex/#comments</comments>
		<pubDate>Fri, 25 Jan 2008 07:39:39 +0000</pubDate>
		<dc:creator>Peter deHaan</dc:creator>
				<category><![CDATA[Fonts]]></category>
		<category><![CDATA[@font face]]></category>
		<category><![CDATA[fontFamily]]></category>
		<category><![CDATA[unicode range]]></category>

		<guid isPermaLink="false">http://blog.flexexamples.com/2008/01/24/specifying-custom-named-unicode-ranges-in-flex/</guid>
		<description><![CDATA[<p>We&#8217;ve looked at general font embedding and unicode ranges before in previous examples (see <a href="http://blog.flexexamples.com/2007/08/06/embedding-and-animating-fonts-in-a-flex-application/">&#8220;Embedding and animating fonts in a Flex application&#8221;</a> and <a href="http://blog.flexexamples.com/2007/08/07/specifying-certain-unicode-ranges-for-embedded-fonts/">&#8220;Specifying certain unicode-ranges for embedded fonts&#8221;</a>), but this example will show you how you can embed a named range of unicode characters into an application by editing your flex-config.xml file [...]]]></description>
			<content:encoded><![CDATA[<p>We&#8217;ve looked at general font embedding and unicode ranges before in previous examples (see <a href="http://blog.flexexamples.com/2007/08/06/embedding-and-animating-fonts-in-a-flex-application/">&#8220;Embedding and animating fonts in a Flex application&#8221;</a> and <a href="http://blog.flexexamples.com/2007/08/07/specifying-certain-unicode-ranges-for-embedded-fonts/">&#8220;Specifying certain unicode-ranges for embedded fonts&#8221;</a>), but this example will show you how you can embed a named range of unicode characters into an application by editing your flex-config.xml file and specifying unicode ranges.</p>
<p>Full code after the jump.</p>
<p><span id="more-475"></span></p>
<p>OK, so the first question you may have is: &#8220;Sounds great, but why would I want to embed a font in my Flex application?&#8221;. Reasonable question, and I&#8217;m glad you asked. Well, perhaps you want to rotate some text, or set the alpha on some text so it is semi-transparent. In order to do either of these things you need to embed a font face into your Flex application. But as you may expect, embedding fonts and additional assets make your SWF file sizes bigger, so you should be aware of a few small details before you go embedding a number of fonts in your applications.</p>
<p>Lets start off with a simple example. Consider the following code:</p>
<pre class="code">
&lt;?xml version="1.0" encoding="utf-8"?&gt;
&lt;!-- http://blog.flexexamples.com/2008/01/24/specifying-custom-named-unicode-ranges-in-flex/ --&gt;
&lt;mx:Application xmlns:mx="http://www.adobe.com/2006/mxml"
        layout="vertical"
        verticalAlign="top"
        backgroundColor="white"&gt;

    &lt;mx:Style&gt;
        @font-face {
            src: local("Base 02");
            fontFamily: Base02Embedded;
        }
    &lt;/mx:Style&gt;

    &lt;mx:Label text="The quick brown fox jumped over the lazy dog."
            fontFamily="Base02Embedded"
            fontSize="16"
            rotation="15"
            truncateToFit="false" /&gt;

&lt;/mx:Application&gt;
</pre>
<p>This code defines a @font-face style in an &lt;mx:Style /&gt; block. Note that it only specifies a <code>src</code> attribute and <code>fontFamily</code> style. What the code is doing is embedding the whole available unicode range for the Base02 font.</p>
<p>If you export a release (non-debugging) version of the previous example, the SWF is 272,788 bytes (approximagely 266 KB). By comparison, if you didn&#8217;t embed a font into your application, the SWF size would only be 152,415 bytes (approximately 148 KB, or 55% of the embedded font example SWF file size).</p>
<p>So, what can we do if we want to embed a font, but not increase the size of our SWF file significantly? Correct, you can specify unicode ranges! Note that we have a few options:</p>
<p>1) The following unicode range specifies the whole range of uppercase, lowercase, symbols and punctuation:</p>
<pre class="code">
unicode-range: U+0021-U+007B;
</pre>
<p>2) The following unicode range specifies all uppercase, lowercase characters as well as numbers:</p>
<pre class="code">
unicode-range:
    U+0030-U+0039, /* 0-9 */
    U+0041-U+0051, /* Uppercase A-Z */
    U+0052-U+007A; /* Lowercase a-z */
</pre>
<p>3) The following unicode range specifies only the letters used in the string being displayed:</p>
<pre class="code">
unicode-range:
    U+0054-U+0054, /* T */
    U+0061-U+007A, /* a-z */
    U+002E-U+002E; /* . (period) */
</pre>
<p>So now that we have a slightly better understanding of font embedding and unicode ranges, lets look at setting up our own custom ranges so we can specify unicode ranges by name instead of slightly cryptic unicode numbers.</p>
<p>First, locate your flex-config.xml XML document in your particular Flex SDK framework directory of choice. It should be located in your particular Flex SDK&#8217;s /frameworks/ directory. If you are using Flex Builder 3 standalone on Windows, that path would probably look something like the following:<br />
C:\Program Files\Adobe\Flex Builder 3\sdks\3.0.0\frameworks\flex-config.xml</p>
<p>Open up the XML file in your XML editor of choice. If you consider yourself a somewhat unlucky person, you may want to make a backup of the file before editing it. Scroll down until you find a section under &lt;fonts&gt;, then, locate the child node &lt;languages&gt;. You can see that there is currently a single language-range specified, although it is currently commented out. By default, the XML we&#8217;re interested in should look like this:</p>
<pre class="code">
&lt;languages&gt;
    &lt;language-range&gt;
        &lt;lang&gt;englishRange&lt;/lang&gt;
        &lt;range&gt;U+0020-U+007E&lt;/range&gt;
    &lt;/language-range&gt;
&lt;/languages&gt;
</pre>
<p>Note that it specifies a &lt;language-range /&gt; node with the custom name &#8220;englishRange&#8221; and a unicode range of U+0020 through U+007E. To use this range, simply uncomment the XML node, and save the file. Note, you may need to clean or recompile your project in Flex Builder. At this point, you can do something like the following in Flex Builder:</p>
<pre class="code">
&lt;mx:Style&gt;
    @font-face {
        src: local("Base 02");
        fontFamily: Base02Embedded;
        unicode-range: englishRange; /* was: U+0020-U+007E */
    }
&lt;/mx:Style&gt;
</pre>
<p>As you can see, using a named custom unicode-range is a lot simpler, easier to remember, and a lot more reusable.</p>
<p>Similar to defining unicode ranges in your &lt;mx:Script /&gt; blocks, you can specify multiple ranges in your flex-config.xml file by separating the ranges with commas, as seen in the following snippet:</p>
<pre class="code">
&lt;language-range&gt;
    &lt;lang&gt;UpperLower&lt;/lang&gt;
    &lt;range&gt;U+0020, U+0041-U+005A, U+0061-U+007A&lt;/range&gt;
&lt;/language-range&gt;
</pre>
<p>This code embeds the space character (U+0020), uppercase characters (U+0041 to U+005A), and lowecase characters (U+0061 to U+007A). Then, to use the new range in your Flex applications, you can use the following snippet:</p>
<pre class="code">
&lt;mx:Style&gt;
    @font-face {
        src: local(&quot;Base 02&quot;);
        fontFamily: Base02Embedded;
        <strong style="color:red;">unicode-range: UpperLower;</strong>
    }
&lt;/mx:Style&gt;
</pre>
<p>If you want to specify multiple custom unicode ranges, simply add more children to the &lt;languages /&gt; node in the flex-config.xml file, as seen in the following snippet:</p>
<pre class="code">
&lt;languages&gt;
    &lt;language-range&gt;
        &lt;lang&gt;englishRange&lt;/lang&gt;
        &lt;range&gt;U+0020-U+0026, U+0027-U+007E&lt;/range&gt;
    &lt;/language-range&gt;
    &lt;language-range&gt;
        &lt;lang&gt;Uppercase&lt;/lang&gt;
        &lt;range&gt;U+0020,U+0041-U+005A&lt;/range&gt;
    &lt;/language-range&gt;
    &lt;language-range&gt;
        &lt;lang&gt;Lowercase&lt;/lang&gt;
        &lt;range&gt;U+0020,U+0061-U+007A&lt;/range&gt;
    &lt;/language-range&gt;
    &lt;language-range&gt;
        &lt;lang&gt;Numerals&lt;/lang&gt;
        &lt;range&gt;U+0030-U+0039,U+002E&lt;/range&gt;
    &lt;/language-range&gt;
    &lt;language-range&gt;
        &lt;lang&gt;Punctuation&lt;/lang&gt;
        &lt;range&gt;U+0020-U+002F,U+003A-U+0040,U+005B-U+0060,U+007B-U+007E&lt;/range&gt;
    &lt;/language-range&gt;
    &lt;language-range&gt;
        &lt;lang&gt;Basic Latin&lt;/lang&gt;
        &lt;range&gt;U+0020-U+002F,U+0030-U+0039,U+003A-U+0040,U+0041-U+005A,U+005B-U+0060,U+0061-U+007A,U+007B-U+007E&lt;/range&gt;
    &lt;/language-range&gt;
&lt;/languages&gt;
</pre>
<p>You may have noticed that last language-range, &#8220;Basic Latin&#8221;, had a space in the name. In order to use the custom unicode range in your Flex application, simply wrap the name in double-quotes, as seen in the following snippet:</p>
<pre class="code">
unicode-range: "Basic Latin";
</pre>
<p>There you have it, using named unicode ranges in your Flex applications. For a few samples of common unicode ranges, check out the flash-unicode-table.xml XML file in the same directory as your flex-config.xml file. If you are using Flex Builder 3 standalone on Windows, that path would probably look something like the following:<br />
C:\Program Files\Adobe\Flex Builder 3\sdks\3.0.0\frameworks\flash-unicode-table.xml</p>
<p class="construction">One last word of advice. Since your flex-config.xml file is unique to each installed SDK, you may need to make the same changes to both your Flex 2.0.1 SDK builds and Flex 3 builds if you switch between SDKs regularly. Also, if you download nightly builds from the <a href="http://labs.adobe.com/technologies/flex/sdk/flex3sdk.html">Flex 3 SDK nightly builds</a> download page on the <a href="http://labs.adobe.com/">Adobe Labs</a> site, you may need to back up your flex-config.xml file before overwriting the currently installed SDK directory.</p>
<p>Happy Flexing!</p>
<div class="evernoteSiteMemory"><a href="javascript:" onclick="Evernote.doClip({title: 'Specifying custom named unicode ranges in Flex on FlexExamples.com',url: 'http://blog.flexexamples.com/2008/01/24/specifying-custom-named-unicode-ranges-in-flex/',contentID: 'post-475',code: 'Pete9667',suggestNotebook: 'FlexExamples',suggestTags: '@font face,fontFamily,unicode range',providerName: 'FlexExamples.com',styling: 'text' });return false" class="evernoteSiteMemoryLink"><img src="http://static.evernote.com/article-clipper-remember.png" class="evernoteSiteMemoryButton" />
				</a>				<div class="evernoteSiteMemoryClear">&nbsp;</div>
</div>]]></content:encoded>
			<wfw:commentRss>http://blog.flexexamples.com/2008/01/24/specifying-custom-named-unicode-ranges-in-flex/feed/</wfw:commentRss>
		<slash:comments>5</slash:comments>
		</item>
		<item>
		<title>Customizing the Flex DateChooser control</title>
		<link>http://blog.flexexamples.com/2007/12/21/customizing-the-flex-datechooser-control/</link>
		<comments>http://blog.flexexamples.com/2007/12/21/customizing-the-flex-datechooser-control/#comments</comments>
		<pubDate>Sat, 22 Dec 2007 07:21:15 +0000</pubDate>
		<dc:creator>Peter deHaan</dc:creator>
				<category><![CDATA[DateBase]]></category>
		<category><![CDATA[DateChooser]]></category>
		<category><![CDATA[headerStyleName]]></category>
		<category><![CDATA[todayColor]]></category>
		<category><![CDATA[todayStyleName]]></category>
		<category><![CDATA[unicode range]]></category>
		<category><![CDATA[weekDayStyleName]]></category>

		<guid isPermaLink="false">http://blog.flexexamples.com/2007/12/21/customizing-the-flex-datechooser-control/</guid>
		<description><![CDATA[<p>The following example shows how you can customize the DateChooser control in Flex by using an embedded font, customizing the header styles, week day names, week day name styles, and colors by setting various styles and properties.</p> <p></p> <p class="download"><a href="http://blog.flexexamples.com/wp-content/uploads/DateChooser_headerStyleName_test/main.mxml">View MXML</a></p> &#60;?xml version="1.0" encoding="utf-8"?&#62; &#60;!-- http://blog.flexexamples.com/2007/12/21/customizing-the-flex-datechooser-control/ --&#62; &#60;mx:Application xmlns:mx="http://www.adobe.com/2006/mxml" layout="vertical" verticalAlign="middle" backgroundColor="white"&#62; &#60;mx:Style&#62; @font-face [...]]]></description>
			<content:encoded><![CDATA[<p>The following example shows how you can customize the DateChooser control in Flex by using an embedded font, customizing the header styles, week day names, week day name styles, and colors by setting various styles and properties.</p>
<p><span id="more-391"></span></p>
<p class="download"><a href="http://blog.flexexamples.com/wp-content/uploads/DateChooser_headerStyleName_test/main.mxml">View MXML</a></p>
<pre class="code">
&lt;?xml version="1.0" encoding="utf-8"?&gt;
&lt;!-- http://blog.flexexamples.com/2007/12/21/customizing-the-flex-datechooser-control/ --&gt;
&lt;mx:Application xmlns:mx="http://www.adobe.com/2006/mxml"
        layout="vertical"
        verticalAlign="middle"
        backgroundColor="white"&gt;

    &lt;mx:Style&gt;
        @font-face {
            src: local("Base 02");
            fontFamily: Base02Embedded;
            unicode-range:
                U+0030-U+0039, /* 0-9 */
                U+0041-U+0051, /* Uppercase A-Z */
                U+0052-U+007A, /* Lowercase a-z */
                U+002F-U+002F; /* slash (/) */
        }

        DateChooser {
            cornerRadius: 0; /* pixels */
            headerColors: black, black;
            borderColor: black;
            themeColor: black;
            fontFamily: Base02Embedded;
            todayColor: red;
            todayStyleName: myTodayStyleName;
            headerStyleName: myHeaderStyleName;
            weekDayStyleName: myWeekDayStyleName;
            dropShadowEnabled: true;
        }

        .myTodayStyleName {
            color: white;
        }

        .myWeekDayStyleName {
            fontWeight: normal;
        }

        .myHeaderStyleName {
            color: red;
            fontSize: 16;
            fontWeight: normal;
        }
    &lt;/mx:Style&gt;

    &lt;mx:Script&gt;
        &lt;![CDATA[
            import mx.formatters.DateBase;

            private function dateChooser_init():void {
                dateChooser.dayNames = DateBase.dayNamesShort;
            }
        ]]&gt;
    &lt;/mx:Script&gt;

    &lt;mx:DateChooser id="dateChooser"
            initialize="dateChooser_init();" /&gt;

&lt;/mx:Application&gt;
</pre>
<p class="information"><a href="http://blog.flexexamples.com/wp-content/uploads/DateChooser_headerStyleName_test/bin/srcview/index.html">View source</a> is enabled in the following example.</p>
<p><iframe src="http://blog.flexexamples.com/wp-content/uploads/DateChooser_headerStyleName_test/bin/main.html" width="100%" height="300"></iframe></p>
<p class="alert">Base 02 font by <a href="http://www.stereo-type.net/">www.stereo-type.net</a>.</p>
<p>For an example of using embedded fonts with the Flex DateField control, see <a href="http://blog.flexexamples.com/2007/12/16/embedding-fonts-for-the-flex-datefield-control/">&#8220;Embedding fonts for the Flex DateField control&#8221;</a>.</p>
<div class="evernoteSiteMemory"><a href="javascript:" onclick="Evernote.doClip({title: 'Customizing the Flex DateChooser control on FlexExamples.com',url: 'http://blog.flexexamples.com/2007/12/21/customizing-the-flex-datechooser-control/',contentID: 'post-391',code: 'Pete9667',suggestNotebook: 'FlexExamples',suggestTags: 'headerStyleName,todayColor,todayStyleName,unicode range,weekDayStyleName',providerName: 'FlexExamples.com',styling: 'text' });return false" class="evernoteSiteMemoryLink"><img src="http://static.evernote.com/article-clipper-remember.png" class="evernoteSiteMemoryButton" />
				</a>				<div class="evernoteSiteMemoryClear">&nbsp;</div>
</div>]]></content:encoded>
			<wfw:commentRss>http://blog.flexexamples.com/2007/12/21/customizing-the-flex-datechooser-control/feed/</wfw:commentRss>
		<slash:comments>6</slash:comments>
		</item>
		<item>
		<title>Embedding fonts for the Flex DateField control</title>
		<link>http://blog.flexexamples.com/2007/12/16/embedding-fonts-for-the-flex-datefield-control/</link>
		<comments>http://blog.flexexamples.com/2007/12/16/embedding-fonts-for-the-flex-datefield-control/#comments</comments>
		<pubDate>Sun, 16 Dec 2007 17:05:13 +0000</pubDate>
		<dc:creator>Peter deHaan</dc:creator>
				<category><![CDATA[DateChooser]]></category>
		<category><![CDATA[DateField]]></category>
		<category><![CDATA[@font face]]></category>
		<category><![CDATA[unicode range]]></category>

		<guid isPermaLink="false">http://blog.flexexamples.com/2007/12/16/embedding-fonts-for-the-flex-datefield-control/</guid>
		<description><![CDATA[<p>The following example shows how you can embed fonts for use with the DateField control in Flex. Note that we embed both the normal and bold font weights since by default the month and year are bold in the DateChooser sub-component.</p> <p>Full code after the jump.</p> <p></p> <p class="download"><a href="http://blog.flexexamples.com/wp-content/uploads/DateField_fontFamily_test/main.mxml">View MXML</a></p> &#60;?xml version="1.0" encoding="utf-8"?&#62; &#60;!-- [...]]]></description>
			<content:encoded><![CDATA[<p>The following example shows how you can embed fonts for use with the DateField control in Flex. Note that we embed both the normal and bold font weights since by default the month and year are bold in the DateChooser sub-component.</p>
<p>Full code after the jump.</p>
<p><span id="more-372"></span></p>
<p class="download"><a href="http://blog.flexexamples.com/wp-content/uploads/DateField_fontFamily_test/main.mxml">View MXML</a></p>
<pre class="code">
&lt;?xml version="1.0" encoding="utf-8"?&gt;
&lt;!-- http://blog.flexexamples.com/2007/12/16/embedding-fonts-for-the-flex-datefield-control/ --&gt;
&lt;mx:Application xmlns:mx="http://www.adobe.com/2006/mxml"
        layout="vertical"
        verticalAlign="top"
        backgroundColor="white"&gt;

    &lt;mx:Style&gt;
        @font-face {
            src: local("Comic Sans MS");
            fontFamily: "ComicEmbedded";
            fontWeight: normal;
            unicode-range: U+0030-U+0039, /* 0-9 */
                U+002F-U+002F; /* slash (/) */
        }

        @font-face {
            src: local("Comic Sans MS");
            fontFamily: "ComicEmbedded";
            fontWeight: bold;
            unicode-range:
                U+0030-U+0039, /* 0-9 */
                U+0041-U+0051, /* Uppercase A-Z */
                U+0052-U+007A; /* Lowercase a-z */
        }
    &lt;/mx:Style&gt;

    &lt;mx:DateField id="dateField"
            fontFamily="ComicEmbedded"
            color="red" /&gt;

&lt;/mx:Application&gt;
</pre>
<p class="information"><a href="http://blog.flexexamples.com/wp-content/uploads/DateField_fontFamily_test/bin/srcview/index.html">View source</a> is enabled in the following example.</p>
<p><iframe src="http://blog.flexexamples.com/wp-content/uploads/DateField_fontFamily_test/bin/main.html" width="100%" height="300"></iframe></p>
<div class="evernoteSiteMemory"><a href="javascript:" onclick="Evernote.doClip({title: 'Embedding fonts for the Flex DateField control on FlexExamples.com',url: 'http://blog.flexexamples.com/2007/12/16/embedding-fonts-for-the-flex-datefield-control/',contentID: 'post-372',code: 'Pete9667',suggestNotebook: 'FlexExamples',suggestTags: '@font face,unicode range',providerName: 'FlexExamples.com',styling: 'text' });return false" class="evernoteSiteMemoryLink"><img src="http://static.evernote.com/article-clipper-remember.png" class="evernoteSiteMemoryButton" />
				</a>				<div class="evernoteSiteMemoryClear">&nbsp;</div>
</div>]]></content:encoded>
			<wfw:commentRss>http://blog.flexexamples.com/2007/12/16/embedding-fonts-for-the-flex-datefield-control/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Specifying certain unicode-ranges for embedded fonts</title>
		<link>http://blog.flexexamples.com/2007/08/07/specifying-certain-unicode-ranges-for-embedded-fonts/</link>
		<comments>http://blog.flexexamples.com/2007/08/07/specifying-certain-unicode-ranges-for-embedded-fonts/#comments</comments>
		<pubDate>Wed, 08 Aug 2007 05:15:44 +0000</pubDate>
		<dc:creator>Peter deHaan</dc:creator>
				<category><![CDATA[Embed]]></category>
		<category><![CDATA[Fonts]]></category>
		<category><![CDATA[@font face]]></category>
		<category><![CDATA[easing]]></category>
		<category><![CDATA[fontAntiAliasType]]></category>
		<category><![CDATA[unicode range]]></category>

		<guid isPermaLink="false">http://blog.flexexamples.com/2007/08/07/specifying-certain-unicode-ranges-for-embedded-fonts/</guid>
		<description><![CDATA[<p>In a previous post (&#8220;<a href="http://blog.flexexamples.com/2007/08/06/embedding-and-animating-fonts-in-a-flex-application/">Embedding and animating fonts in a Flex application</a>&#8220;), we looked at embedding a font in a Flex application so we could animate, rotate, and set the alpha for a Text control. Well, as we learnt, sometimes embedding a whole font face can dramatically increase the size of the final SWF [...]]]></description>
			<content:encoded><![CDATA[<p>In a previous post (&#8220;<a href="http://blog.flexexamples.com/2007/08/06/embedding-and-animating-fonts-in-a-flex-application/">Embedding and animating fonts in a Flex application</a>&#8220;), we looked at embedding a font in a Flex application so we could animate, rotate, and set the alpha for a Text control. Well, as we learnt, sometimes embedding a whole font face can dramatically increase the size of the final SWF output. In this post we&#8217;ll look at only specifying a certain range of characters for an embedded font, which will help reduce file sizes.</p>
<p>Full code after the jump.</p>
<p><span id="more-66"></span></p>
<p>Before we get too far, we&#8217;ll quickly look at some of the font basics. If you&#8217;re a Windows user, a good place to start is with the Character Map application. Its a little Window&#8217;s utility that gets installed on most modern operating systems and lets you quickly browse a font&#8217;s supported characters, different character sets, filter characters by Unicode subranges, search for certain characters (such as &copy; or &reg;), see a characters Unicode value as well as character code. It also lets you quickly copy certain characters to the clipboard for easy copy-pasting between applications. Because I can never remember where the application gets installed, or where to find its icon, it is usually just easiest to type &#8220;charmap&#8221; from a command prompt. If you have a modern-day keyboard, hit Windows+R to bring up the Run dialog, type &#8220;charmap&#8221;, hit Enter, and get ready to be amazed! Most of the features I mentioned before are cleverly hidden behind the &#8220;Advanced view&#8221; checkbox, so if you&#8217;re feeling up to the challenge check that checkbox to go to advanced view, otherwise the basic view will do just fine for now. At the top of the Character Map application is a Font drop down menu which lists all the fonts you currently have installed on your system. If you just downloaded a TrueType font (TTF) and didn&#8217;t install it into the Fonts directory (C:\Windows\Fonts by default), it won&#8217;t be listed here. Don&#8217;t worry if your specific font isn&#8217;t listed here, it isn&#8217;t the end of the world. Select any old font and click around.</p>
<p>If you want to embed the numbers 0-9, you would click on &#8220;0&#8243; and note it&#8217;s Unicode value (U+0030), then click on &#8220;9&#8243; and do the same (U+0039). Now, in your Flex application, you would specify this range in the @font-family style block like so:</p>
<pre class="code">
unicode-range: U+0030-U+0039;
</pre>
<p>If you wanted to specify multiple ranges, you would just separate them with commas:</p>
<pre class="code">
unicode-range:
    U+0030-U+0039, /* 0-9 */
    U+0041-U+0051, /* Uppercase A-Z */
    U+0052-U+007A; /* Lowercase a-z */
</pre>
<p>And if you just want to embed the whole range of all uppercase, lowercase, punctuation, and symbols, you could just specify the following unicode range:</p>
<pre class="code">
@font-face {
    src: url('assets/base02.ttf');
    font-family: Base02;
    unicode-range: U+0021-U+007B; /* whole range of uppercase, lowercase, symbols and punctuation. */
}
</pre>
<p>Again, use the character map if you want to find additional character such as the copyright symbol (&#0169;) or other symbols.</p>
<p class="alert">Remember, all fonts may not include special &#8220;extended&#8221; characters such as copyright symbols, dollar signs, fractions, pound signs, euro signs, etc. Make sure you check that your font includes the characters you need.</p>
<p>Now, with that out of the way, lets look at a full sample of unicode-range embedding in action!</p>
<p class="download"><a href="http://blog.flexexamples.com/wp-content/uploads/Font_antiAliasType_test_2/main1.mxml">View MXML</a></p>
<pre class="code" lang="actionscript">
&lt;?xml version="1.0" encoding="utf-8"?&gt;
&lt;!-- http://blog.flexexamples.com/2007/08/07/specifying-certain-unicode-ranges-for-embedded-fonts/ --&gt;
&lt;mx:Application xmlns:mx="http://www.adobe.com/2006/mxml"
        layout="vertical"
        verticalAlign="middle"
        backgroundColor="white"&gt;

    &lt;mx:Script&gt;
        &lt;![CDATA[
            /* Import all the easing classes so its
               easier to switch between them on the
               fly without tweaking import statements. */
            import mx.effects.easing.*;
        ]]&gt;
    &lt;/mx:Script&gt;

    &lt;mx:Style&gt;
        @font-face {
            src: url('assets/base02.ttf');
            font-family: Base02;
            unicode-range: U+0021-U+007B; /* whole range of uppercase, lowercase, symbols and punctuation. */
        }

        .MyEmbeddedFont {
            font-family: Base02;
            font-size: 14px;
        }
    &lt;/mx:Style&gt;

    &lt;!-- Set zoom effect for 2.5 seconds (2500 milliseconds) and use the Elastic.easeOut easing method. --&gt;
    &lt;mx:Zoom id="zoom" duration="2500" easingFunction="Elastic.easeOut" target="{embeddedText}" /&gt;

    &lt;!-- Use advanced font anti-aliasing for the embedded font, set the rotation to 5 degrees, alpha to 80% and loop the animation. --&gt;
    &lt;mx:Text id="embeddedText" text="The quick brown fox jumped over the lazy dog." styleName="MyEmbeddedFont" rotation="5" alpha="0.8" fontAntiAliasType="advanced" creationComplete="zoom.play();" effectEnd="zoom.play()" /&gt;

&lt;/mx:Application&gt;
</pre>
<p>Shocking? No, not really, because we saw the new unicode-range style earlier in the pre-code discussion. But what kind of filesize savings did we encounter by only embedding a &#8220;small range&#8221; of characters? Well, in this case, none really. The Base02 font really only has the regular letters, numbers, punctuation and symbols to begin with, so our SWF size is still ~260 KB, same as the previous article where we didn&#8217;t specify a range at all.</p>
<p>But what if we only specify the exact characters that we need, the uppercase &#8220;T&#8221;, full range of lowercase letters and the period? Well, as luck has it, I did just that:</p>
<p class="download"><a href="http://blog.flexexamples.com/wp-content/uploads/Font_antiAliasType_test_2/main2.mxml">View MXML</a></p>
<pre class="code" lang="actionscript">
&lt;?xml version="1.0" encoding="utf-8"?&gt;
&lt;!-- http://blog.flexexamples.com/2007/08/07/specifying-certain-unicode-ranges-for-embedded-fonts/ --&gt;
&lt;mx:Application xmlns:mx="http://www.adobe.com/2006/mxml"
        layout="vertical"
        verticalAlign="middle"
        backgroundColor="white"&gt;

    &lt;mx:Script&gt;
        &lt;![CDATA[
            /* Import all the easing classes so its
               easier to switch between them on the
               fly without tweaking import statements. */
            import mx.effects.easing.*;
        ]]&gt;
    &lt;/mx:Script&gt;

    &lt;mx:Style&gt;
        @font-face {
            src: url('assets/base02.ttf');
            font-family: Base02;
            unicode-range:
                U+0054-U+0054, /* T */
                U+0061-U+007A, /* a-z */
                U+002E-U+002E; /* . (period) */
        }

        .MyEmbeddedFont {
            font-family: Base02;
            font-size: 14px;
        }
    &lt;/mx:Style&gt;

    &lt;!-- Set zoom effect for 2.5 seconds (2500 milliseconds) and use the Elastic.easeOut easing method. --&gt;
    &lt;mx:Zoom id="zoom" duration="2500" easingFunction="Elastic.easeOut" target="{embeddedText}" /&gt;

    &lt;!-- Use advanced font anti-aliasing for the embedded font, set the rotation to 5 degrees, alpha to 80% and loop the animation. --&gt;
    &lt;mx:Text id="embeddedText" text="The quick brown fox jumped over the lazy dog." styleName="MyEmbeddedFont" rotation="5" alpha="0.8" fontAntiAliasType="advanced" creationComplete="zoom.play();" effectEnd="zoom.play()" /&gt;

&lt;/mx:Application&gt;
</pre>
<p>Yeah, the same big snippet for a minor little tweak, but hey. I&#8217;m sure it makes somebody&#8217;s life easier if they can grab all the code in one place instead of copying from two sources.</p>
<p>So, with the bare minimum of characters embedded, what is the new file size of the SWF? My main SWF file is now down to 193 KB (down from ~260 KB), which is about 74% of its original size, and only 46 KB larger than the same example without any embedded font. Not too bad for a tiny bit of work! Of course, its pretty easy when you know exactly which characters are used. If we were using the font for multiple text fields or a TextInput/TextArea control you would probably need to embed the whole range of characters since you couldn&#8217;t be sure of what the user would be entering.</p>
<p class="information">View source is enabled in the following example.</p>
<p><iframe src="http://blog.flexexamples.com/wp-content/uploads/Font_antiAliasType_test_2/bin/main.html" width="100%" height="200"></iframe></p>
<p class="alert">Base 02 font by <a href="http://www.stereo-type.net/">www.stereo-type.net</a>.</p>
<div class="evernoteSiteMemory"><a href="javascript:" onclick="Evernote.doClip({title: 'Specifying certain unicode-ranges for embedded fonts on FlexExamples.com',url: 'http://blog.flexexamples.com/2007/08/07/specifying-certain-unicode-ranges-for-embedded-fonts/',contentID: 'post-66',code: 'Pete9667',suggestNotebook: 'FlexExamples',suggestTags: '@font face,easing,fontAntiAliasType,unicode range',providerName: 'FlexExamples.com',styling: 'text' });return false" class="evernoteSiteMemoryLink"><img src="http://static.evernote.com/article-clipper-remember.png" class="evernoteSiteMemoryButton" />
				</a>				<div class="evernoteSiteMemoryClear">&nbsp;</div>
</div>]]></content:encoded>
			<wfw:commentRss>http://blog.flexexamples.com/2007/08/07/specifying-certain-unicode-ranges-for-embedded-fonts/feed/</wfw:commentRss>
		<slash:comments>8</slash:comments>
		</item>
	</channel>
</rss>

