<?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>Mozilla Hacks - the Web developer blog &#187; John Daggett</title>
	<atom:link href="http://hacks.mozilla.org/author/jdaggett/feed/" rel="self" type="application/rss+xml" />
	<link>http://hacks.mozilla.org</link>
	<description>hacks.mozilla.org</description>
	<lastBuildDate>Wed, 08 Feb 2012 22:52:35 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.3.1</generator>
		<item>
		<title>Firefox 4: OpenType font feature support</title>
		<link>http://hacks.mozilla.org/2010/11/firefox-4-font-feature-support/</link>
		<comments>http://hacks.mozilla.org/2010/11/firefox-4-font-feature-support/#comments</comments>
		<pubDate>Wed, 10 Nov 2010 01:32:30 +0000</pubDate>
		<dc:creator>John Daggett</dc:creator>
				<category><![CDATA[@font-face]]></category>
		<category><![CDATA[CSS]]></category>
		<category><![CDATA[Featured Article]]></category>
		<category><![CDATA[Firefox 4]]></category>

		<guid isPermaLink="false">http://hacks.mozilla.org/?p=6599</guid>
		<description><![CDATA[When @font-face support was introduced in Firefox 3.5, web authors were suddenly given a way of dramatically enhancing the typography used on their sites.  With all major browsers slated to soon support WOFF fonts offered by many font vendors, the range of fonts available on the web is far wider than it was just two [...]]]></description>
			<content:encoded><![CDATA[<p>When <a href="https://developer.mozilla.org/en/css/@font-face">@font-face</a> support was introduced in Firefox 3.5, web authors were suddenly given a way of dramatically enhancing the typography used on their sites.  With all major browsers slated to soon support WOFF fonts offered by many font vendors, the range of fonts available on the web is far wider than it was just two years ago.</p>
<p style="display: none; margin: 0; padding: 0;">
<!-- Hi Mom!  This paragraph is for hacking WordPress --><br />
<!-- Myriad Pro from Adobe via Typekit --><br />
<script type="text/javascript" src="http://use.typekit.com/xti0aim.js"></script><br />
<script type="text/javascript">try{Typekit.load();}catch(e){}</script></p>
<style type="text/css">
h4 + p { margin-top: 1em; }
#content-main { font-family: myriad-pro-1,myriad-pro-2, Helvetica,"Helvetica Neue",Arial,sans-serif; }
#content-main .post a img { border-width: 2px; } 
</style>
</p>
<p>The OpenType format has long provided font designers ways of including a rich set of variations in their fonts, from ligatures and swashes to small caps and tabular figures. The OpenType specification describes these features, identifying each with a unique feature tag but they have typically only been available to those using professional publishing applications such as Adobe InDesign. When glyphs are selected for a particular sequence of characters and positioned for rendering, these features affect both glyph selection and positioning.  Firefox currently renders using a font&#8217;s default feature settings; it would be much more interesting to provide web authors with a way of controlling these font features via CSS.</p>
<p>Included among the many new features in Firefox 4 is the next step, support for controlling OpenType font features directly via CSS.  The <a href="https://developer.mozilla.org/en/CSS/-moz-font-feature-settings">-moz-font-feature-settings CSS property</a> permits control over kerning, ligatures, alternates, real small caps and stylistic sets to name just a few.</p>
<p>The CSS3 Fonts specification contains a number of <a href="http://dev.w3.org/csswg/css3-fonts/#font-variant-ligatures-prop">new subproperties of font-variant</a>.  These will eventually provide much better author control over font features but for Firefox 4 only the low-level <a href="https://developer.mozilla.org/en/CSS/-moz-font-feature-settings">-moz-font-feature-settings CSS property</a> is supported.  With this authors can enable and disable OpenType font features directly:</p>

<div class="wp_syntax"><div class="code"><pre class="css" style="font-family:monospace;"><span style="color: #6666ff;">.altstyles</span> <span style="color: #00AA00;">&#123;</span>
  <span style="color: #808080; font-style: italic;">/* format: feature-tag=[0,1] with 0 to disable, 1 to enable */</span>
  <span style="color: #808080; font-style: italic;">/* dlig = discretionary ligatures, ss01 = stylistic set 1 */</span>
  -moz-font-feature-settings<span style="color: #00AA00;">:</span> <span style="color: #ff0000;">&quot;dlig=1,ss01=1&quot;</span><span style="color: #00AA00;">;</span>
<span style="color: #00AA00;">&#125;</span></pre></div></div>

<p>For reference, a complete list of registered OpenType features can be found <a href="http://www.microsoft.com/typography/otspec/featurelist.htm">here</a>. The folks at FontFont provide a <a href="http://www.fontfont.com/opentype/FF_OT_UserGuide_v2.pdf">nice visual guide to OpenType features</a>.</p>
<h4>Ligatures and Contextual Alternates</h4>
<p>Font designers often include simple ligatures and kerning data in their fonts but some go beyond these and spend a lot of time creating special ligatures and contextual alternate glyphs to enhance a given design. The <a href="http://www.underware.nl/site2/index.php?id1=bello&amp;id2=features">Bello Pro script font</a> from Underware is a brush-like design that includes many special ligatures (click image to view):</p>
<p><a href="http://people.mozilla.org/~jdaggett/webfonts/sugarspice.html"><img src="http://people.mozilla.org/~jdaggett/webfonts/sugarspice.png"></a></p>
<p>Note the special ligatures for &#8220;and&#8221; and &#8220;by&#8221;, the use of all small caps and the use of alternate glyphs to enhance the script connection between the letters in &#8220;Smooching&#8221;.  Only font styling is used here, all the text can be selected and copied, there are no images used on the example page.</p>
<h4>Number styles</h4>
<p>Using <a href="http://typekit.com/fonts/minion-pro">Minion Pro from Adobe</a>, available via Typekit, the example below illustrates the use of tabular, monospaced number forms to display columns of data in a way that&#8217;s easy to read and analyze.  When proportional numbers are used, the width of large figures with the same number of digits will vary. Normally this would require using a different, monospaced font.  But with OpenType fonts that provide number formatting features, authors can use a single font without giving up the readibility of large data sets (click image to view):</p>
<p><a href="http://people.mozilla.org/~jdaggett/webfonts/salestable.html"><img src="http://people.mozilla.org/~jdaggett/webfonts/salestable.png"/></a></p>
<p>Fonts may use either tabular or proportional number forms by default; providing access to these features allows authors to use both proportional figures for inline text and tabular figures for tabular data without the need to switch fonts.</p>
<h4>Automatic fractions</h4>
<p>Recipes for American dishes often use fractional amounts.  These can easily be rendered using the automatic fraction feature in OpenType (click image to view):</p>
<p><a href="http://people.mozilla.org/~jdaggett/webfonts/tiramisu.html"><img src="http://people.mozilla.org/~jdaggett/webfonts/tiramisu.png"/></a></p>
<p>Each of the fractions above is written in simple text form, (e.g. 2 1/2), no special Unicode codepoints are used.  For fonts that support automatic fractions, an OpenType layout engine will automatically generate fractional forms for numbers separated by a slash.  These are typically limited to simple fractions, for more complex math expressions markup languages like <a href="https://developer.mozilla.org/en/Mathml">MathML</a> should be used instead.</p>
<h4>Language sensitivity</h4>
<p>Many languages often use a common script and over time differences in usage naturally arise.  Serbian, Macedonian and Bulgarian all use the Cyrillic script but with slightly different glyph forms for some common characters.  OpenType fonts support the ability to specify script-specific and language-specific glyph handling so given the correct lang attribute in the markup of a page, Firefox 4 can now render text in a language-specific way (click image to view):</p>
<p><a href="http://people.mozilla.org/~jdaggett/webfonts/serbianglyphs.html"><img src="http://people.mozilla.org/~jdaggett/webfonts/serbianglyphs.png"/></a></p>
<h4>Arbitrary features</h4>
<p>OpenType defines font feature support using an underlying set of primitives. This allows font designers the ability to create their own features, either for a specialized purpose or as a general feature to be included in a future version of the OpenType specification.  Since the syntax of -moz-font-feature-settings allows for the use of arbitrary feature tags, these can be accessed via CSS.</p>
<p>In the example below, font designer Erik van Blokland of <a href="http://letterror.com/">LettError</a> uses a custom designed set of feature properties to create an interesting animation effect when hovering over text on the page (click image to view):</p>
<p><a href="http://letterror.com/develop/css3/kosmik/"><img src="http://people.mozilla.org/~jdaggett/webfonts/images/ticklemekosmik.png"/></a></p>
<h4>HarfBuzz, an OpenType shaping engine</h4>
<p>The process of selecting and positioning glyphs used to display text runs has in the past always been done via platform libraries such as Uniscribe on Windows and CoreText on  OSX.  To assure more robust and consistent text rendering across platforms, Firefox 4 will use the open source <a href="http://www.freedesktop.org/wiki/Software/HarfBuzz">HarfBuzz OpenType shaping engine</a> on all platforms. In the future this will allow us to integrate support for complex Indic and Southeast Asian scripts that have often been ignored or supported inconsistently in the past.</p>
<h4>A Note About Typekit Use</h4>
<p>All of the Adobe fonts available via the Typekit webfont service provide access to the full range of OpenType features found in the original fonts.  But to access those features you&#8217;ll need to explicitly enable &#8220;All Characters&#8221; under the &#8220;Language Support&#8221; category in the kit editor dialog before publishing.</p>
<h4>Other examples</h4>
<p>(Updated from a <a href="http://hacks.mozilla.org/2009/10/font-control-for-designers/">blog post last year</a>):</p>
<ul>
<li><a href="http://people.mozilla.com/~jkew/feature-samples/MEgalopolis.html">Use of contextual alternates and ornaments</a>
<li><a href="http://people.mozilla.com/~jkew/feature-samples/cooking.html">Another recipe example</a>
<li><a href="http://people.mozilla.com/~jkew/feature-samples/forex.html">Tabular data example</a>
<li><a href="http://people.mozilla.com/~jkew/feature-samples/udhr-turkish.html">Language specific rendering of Turkish</a>
<li><a href="http://people.mozilla.org/~jdaggett/webfonts/historicaltext.html">Rendering historical text</a>
</ul>
<p><em>Update: the content of the examples is now editable!  Edit the text of each example to experiment with the different font features.</em></p>
]]></content:encoded>
			<wfw:commentRss>http://hacks.mozilla.org/2010/11/firefox-4-font-feature-support/feed/</wfw:commentRss>
		<slash:comments>44</slash:comments>
		</item>
		<item>
		<title>beautiful fonts with @font-face</title>
		<link>http://hacks.mozilla.org/2009/06/beautiful-fonts-with-font-face/</link>
		<comments>http://hacks.mozilla.org/2009/06/beautiful-fonts-with-font-face/#comments</comments>
		<pubDate>Thu, 11 Jun 2009 14:22:07 +0000</pubDate>
		<dc:creator>John Daggett</dc:creator>
				<category><![CDATA[35 Days]]></category>
		<category><![CDATA[@font-face]]></category>
		<category><![CDATA[CSS]]></category>
		<category><![CDATA[Feature]]></category>
		<category><![CDATA[Firefox 3.5]]></category>

		<guid isPermaLink="false">http://hacks.mozilla.org/?p=242</guid>
		<description><![CDATA[While Firefox 3.0 improved typographic rendering by introducing support for kerning, ligatures, and multiple weights along with support for rendering complex scripts, authors are still limited to using commonly available fonts in their designs. Firefox 3.5 removes this restriction by introducing support for the CSS @font-face rule, a way of linking to TrueType and OpenType [...]]]></description>
			<content:encoded><![CDATA[<p>While Firefox 3.0 improved typographic rendering by introducing support for kerning, ligatures, and multiple weights along with support for rendering complex scripts, authors are still limited to using commonly available fonts in their designs. Firefox 3.5 removes this restriction by introducing support for the CSS <a href="https://developer.mozilla.org/en/CSS/@font-face">@font-face</a> rule, a way of linking to TrueType and OpenType fonts just as code and images are linked to today. Safari has supported this type of font linking since version 3.1, and Opera has announced that they plan to support it in Opera 10.</p>
<p>Using @font-face for font linking is relatively straightforward. Within a stylesheet, each @font-face rule defines a family name to be used, the font resource to be loaded, and the style characteristics of a given face such as whether it&#8217;s bold or italic. Firefox 3.5 only downloads the fonts as needed, so a stylesheet can list a whole set of fonts of which only a select few will actually be used.</p>

<div class="wp_syntax"><div class="code"><pre class="css" style="font-family:monospace;"><span style="color: #808080; font-style: italic;">/* Graublau Sans Web (www.fonts.info) */</span>
&nbsp;
<span style="color: #a1a100;">@font-face {</span>
  <span style="color: #000000; font-weight: bold;">font-family</span><span style="color: #00AA00;">:</span> Graublau Sans Web<span style="color: #00AA00;">;</span>
  src<span style="color: #00AA00;">:</span> <span style="color: #993333;">url</span><span style="color: #00AA00;">&#40;</span><span style="color: #ff0000; font-style: italic;">GraublauWeb.otf</span><span style="color: #00AA00;">&#41;</span> format<span style="color: #00AA00;">&#40;</span><span style="color: #ff0000;">&quot;opentype&quot;</span><span style="color: #00AA00;">&#41;</span><span style="color: #00AA00;">;</span>
<span style="color: #00AA00;">&#125;</span>
&nbsp;
body <span style="color: #00AA00;">&#123;</span>
  <span style="color: #000000; font-weight: bold;">font-family</span><span style="color: #00AA00;">:</span> Graublau Sans Web<span style="color: #00AA00;">,</span> Lucida Grande<span style="color: #00AA00;">,</span> <span style="color: #993333;">sans-serif</span><span style="color: #00AA00;">;</span> 
<span style="color: #00AA00;">&#125;</span></pre></div></div>

<p>Browsers that support @font-face will render text using Graublau Sans Web while older browsers will render text using either Lucida Grande or the default sans-serif face. Example <a href="http://people.mozilla.org/~jdaggett/demos/simplefontface.html">here</a>: </p>
<p><a href="http://people.mozilla.org/~jdaggett/demos/simplefontface.html"><br />
<img src="http://hacks.mozilla.org/wp-content/uploads/2009/06/graublausanswebdemo.png"/><br />
</a></p>
<p><strong>Digging A Little Deeper</strong></p>
<p>Most font families today consist of only four faces: regular, bold, italic and bold italic. To define each of these faces the <em>font-weight</em> and <em>font-style</em> descriptors are used. These define the style of the face; there&#8217;s no concept of a cascade or inheritance that applies here. Without an explicit definition each of these defaults to a value of &#8216;normal&#8217;:</p>

<div class="wp_syntax"><div class="code"><pre class="css" style="font-family:monospace;"><span style="color: #808080; font-style: italic;">/* Gentium by SIL International   */</span>
<span style="color: #808080; font-style: italic;">/* http://scripts.sil.org/gentium */</span>
&nbsp;
<span style="color: #a1a100;">@font-face {</span>
  <span style="color: #000000; font-weight: bold;">font-family</span><span style="color: #00AA00;">:</span> Gentium<span style="color: #00AA00;">;</span>
  src<span style="color: #00AA00;">:</span> <span style="color: #993333;">url</span><span style="color: #00AA00;">&#40;</span><span style="color: #ff0000; font-style: italic;">Gentium.ttf</span><span style="color: #00AA00;">&#41;</span><span style="color: #00AA00;">;</span>
  <span style="color: #808080; font-style: italic;">/* font-weight, font-style ==&gt; default to normal */</span>
<span style="color: #00AA00;">&#125;</span>
&nbsp;
<span style="color: #a1a100;">@font-face {</span>
  <span style="color: #000000; font-weight: bold;">font-family</span><span style="color: #00AA00;">:</span> Gentium<span style="color: #00AA00;">;</span>
  src<span style="color: #00AA00;">:</span> <span style="color: #993333;">url</span><span style="color: #00AA00;">&#40;</span><span style="color: #ff0000; font-style: italic;">GentiumItalic.ttf</span><span style="color: #00AA00;">&#41;</span><span style="color: #00AA00;">;</span>
  <span style="color: #000000; font-weight: bold;">font-style</span><span style="color: #00AA00;">:</span> <span style="color: #993333;">italic</span><span style="color: #00AA00;">;</span>
<span style="color: #00AA00;">&#125;</span>
&nbsp;
body <span style="color: #00AA00;">&#123;</span> <span style="color: #000000; font-weight: bold;">font-family</span><span style="color: #00AA00;">:</span> Gentium<span style="color: #00AA00;">,</span> Times New Roman<span style="color: #00AA00;">,</span> <span style="color: #993333;">serif</span><span style="color: #00AA00;">;</span> <span style="color: #00AA00;">&#125;</span></pre></div></div>

<p>The <a href="http://people.mozilla.org/~jdaggett/demos/multiplefaces.html">sample text</a> below when rendered with this font family: </p>
<p><a href="http://people.mozilla.org/~jdaggett/demos/multiplefaces.html"><br />
<img src="http://hacks.mozilla.org/wp-content/uploads/2009/06/multiplefaces.png"/><br />
</a></p>
<p>A feature that&#8217;s easy to overlook is that @font-face allows the creation of families with more than just regular and bold faces &#8212; up to nine weights can be defined for a single family. This is true even on Windows, where underlying platform limitations usually restrict font families to just regular and bold weights. Fonts such as those of the Japanese open source <a href="http://mplus-fonts.sourceforge.jp/">M+ Fonts project</a> have as many as seven weights. A selection of these are used in the <a href="http://people.mozilla.org/~jdaggett/demos/multipleweights.html">sample</a> below: </p>
<p><a href="http://people.mozilla.org/~jdaggett/demos/multipleweights.html"><br />
<img src="http://hacks.mozilla.org/wp-content/uploads/2009/06/multipleweights.png"/><br />
</a></p>
<p>In some situations, authors may prefer to use fonts available locally and only download fonts when those faces aren&#8217;t available. This is possible with the use of <em>local()</em> in the definition of the <em>src</em> descriptor of an @font-face rule. The browser will iterate over the list of fonts in the src descriptor until it successfully loads one.</p>

<div class="wp_syntax"><div class="code"><pre class="css" style="font-family:monospace;"><span style="color: #808080; font-style: italic;">/* MgOpen Moderna                      */</span>
<span style="color: #808080; font-style: italic;">/* http://www.zvr.gr/typo/mgopen/index */</span>
&nbsp;
<span style="color: #a1a100;">@font-face {</span>
  <span style="color: #000000; font-weight: bold;">font-family</span><span style="color: #00AA00;">:</span> MyHelvetica<span style="color: #00AA00;">;</span>
  src<span style="color: #00AA00;">:</span> local<span style="color: #00AA00;">&#40;</span><span style="color: #ff0000;">&quot;Helvetica Neue&quot;</span><span style="color: #00AA00;">&#41;</span><span style="color: #00AA00;">,</span> 
       local<span style="color: #00AA00;">&#40;</span><span style="color: #ff0000;">&quot;HelveticaNeue&quot;</span><span style="color: #00AA00;">&#41;</span><span style="color: #00AA00;">,</span> 
       <span style="color: #993333;">url</span><span style="color: #00AA00;">&#40;</span><span style="color: #ff0000; font-style: italic;">MgOpenModernaRegular.ttf</span><span style="color: #00AA00;">&#41;</span><span style="color: #00AA00;">;</span>
<span style="color: #00AA00;">&#125;</span>
&nbsp;
<span style="color: #a1a100;">@font-face {</span>
  <span style="color: #000000; font-weight: bold;">font-family</span><span style="color: #00AA00;">:</span> MyHelvetica<span style="color: #00AA00;">;</span>
  src<span style="color: #00AA00;">:</span> local<span style="color: #00AA00;">&#40;</span><span style="color: #ff0000;">&quot;Helvetica Neue Bold&quot;</span><span style="color: #00AA00;">&#41;</span><span style="color: #00AA00;">,</span> 
       local<span style="color: #00AA00;">&#40;</span><span style="color: #ff0000;">&quot;HelveticaNeue-Bold&quot;</span><span style="color: #00AA00;">&#41;</span><span style="color: #00AA00;">,</span> 
       <span style="color: #993333;">url</span><span style="color: #00AA00;">&#40;</span><span style="color: #ff0000; font-style: italic;">MgOpenModernaBold.ttf</span><span style="color: #00AA00;">&#41;</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>
&nbsp;
body <span style="color: #00AA00;">&#123;</span> <span style="color: #000000; font-weight: bold;">font-family</span><span style="color: #00AA00;">:</span> MyHelvetica<span style="color: #00AA00;">,</span> <span style="color: #993333;">sans-serif</span><span style="color: #00AA00;">;</span> <span style="color: #00AA00;">&#125;</span></pre></div></div>

<p>The screenshot below shows from top to bottom the results on Mac OS X, Windows and Linux for a <a href="http://people.mozilla.org/~jdaggett/demos/localfallback.html">simple testcase</a> that uses the font family defined above: </p>
<p><a href="http://people.mozilla.org/~jdaggett/demos/localfallback.html"><br />
<img src="http://hacks.mozilla.org/wp-content/uploads/2009/06/macwinlinrendering.png"/><br />
</a></p>
<p>The Helvetica Neue font family is available on most Mac OS X systems but generally on neither Windows nor Linux machines. When the example here is rendered on Mac OS X, the local Helvetica Neue faces are used and no font is downloaded. Under Windows and Linux the attempt to load a local font fails and a substitute font &#8212; MgOpen Moderna &#8212; is downloaded and used instead. MgOpen Moderna is designed to be a substitute for Helvetica, so it renders similarly to Helvetica Neue. This way, an author can guarantee text appearance but avoid a font download when it&#8217;s unnecessary.</p>
<p>The name used to refer to a specific font face is the full name for an individual font. Generally it&#8217;s the family name plus the style name (e.g. &#8220;Helvetica Bold&#8221;). Under Mac OS X, the name is listed in the information panel for a given face. Select a single face and choose &#8216;Show Font Info&#8217; from the Preview menu in FontBook: </p>
<p><img src="http://hacks.mozilla.org/wp-content/uploads/2009/06/fontbookinfo.png"/></p>
<p>Similar tools exist under Linux. On Windows, use the <a href="http://www.microsoft.com/typography/FreeToolsOverview.mspx">font properties extension</a>, a free download from Microsoft to view these names. With the extension installed, the properties panel shows information about an individual font. The full name is referred to as the &#8220;Font Name&#8221; on the Name tab: </p>
<p><img src="http://hacks.mozilla.org/wp-content/uploads/2009/06/fontproperties.png"/></p>
<p>Safari only supports PostScript name lookup under Mac OS X, so under Mac OS X Postscript names are also supported. For OpenType PS fonts (often labeled with an .otf extension) the full name is the same as the PostScript name under Windows. So for these fonts, authors are advised to include both the full name and the PostScript name for cross-platform interoperability. </p>
<p><strong>Supporting Many Languages</strong></p>
<p>Many languages suffer from a lack of commonly available fonts. For minority languages and ancient scripts, the options often dwindle to just a handful. The use of @font-face allows authors using these languages to ameliorate this by including fonts with their pages.</p>

<div class="wp_syntax"><div class="code"><pre class="css" style="font-family:monospace;"><span style="color: #a1a100;">@font-face {</span>
  <span style="color: #000000; font-weight: bold;">font-family</span><span style="color: #00AA00;">:</span> Scheherazade<span style="color: #00AA00;">;</span>
  src<span style="color: #00AA00;">:</span> <span style="color: #993333;">url</span><span style="color: #00AA00;">&#40;</span><span style="color: #ff0000; font-style: italic;">fonts/ScheherazadeRegAAT.ttf</span><span style="color: #00AA00;">&#41;</span> format<span style="color: #00AA00;">&#40;</span><span style="color: #ff0000;">&quot;truetype-aat&quot;</span><span style="color: #00AA00;">&#41;</span><span style="color: #00AA00;">,</span> 
       <span style="color: #993333;">url</span><span style="color: #00AA00;">&#40;</span><span style="color: #ff0000; font-style: italic;">fonts/ScheherazadeRegOT.ttf</span><span style="color: #00AA00;">&#41;</span> format<span style="color: #00AA00;">&#40;</span><span style="color: #ff0000;">&quot;opentype&quot;</span><span style="color: #00AA00;">&#41;</span><span style="color: #00AA00;">;</span>
<span style="color: #00AA00;">&#125;</span>
&nbsp;
body <span style="color: #00AA00;">&#123;</span> <span style="color: #000000; font-weight: bold;">font-family</span><span style="color: #00AA00;">:</span> Scheherazade<span style="color: #00AA00;">,</span> <span style="color: #993333;">serif</span><span style="color: #00AA00;">;</span> <span style="color: #00AA00;">&#125;</span></pre></div></div>

<p>Languages such as Arabic require text shaping, where the display of a given character is affected by the characters surrounding it. Different platforms support different rendering technologies to enable text shaping; under Mac OS X, AAT fonts are required while under Windows and Linux OpenType fonts are required. Without a font in a format required for a given platform, text shaping will not be rendered correctly. </p>
<p><a href="http://people.mozilla.org/~jdaggett/demos/arabicfont.html"><br />
<img src="http://hacks.mozilla.org/wp-content/uploads/2009/06/arabicsample.png"/><br />
</a></p>
<p>Under Mac OS X, the AAT version of the font is downloaded. On Windows and Linux, where rendering with AAT fonts is not supported, the download of the AAT font is skipped and the OpenType font is used instead. Hence, the text is rendered correctly on all platforms. </p>
<p><strong>Cross-Site Font Usage</strong></p>
<p>By default, Firefox 3.5 only allows fonts to be loaded for pages served from the same site. This prevents sites from freely using fonts found on other sites. For sites that explicitly want to allow cross-site font sharing, an online font library for example, Firefox 3.5 supports the use of <a href="http://www.w3.org/TR/access-control/">access control headers</a> to control this behavior. By adding an additional header to the HTTP headers sent with font files, sites can enable cross-site usage.</p>

<div class="wp_syntax"><div class="code"><pre class="text" style="font-family:monospace;"># example Apache .htaccess file to add access control header
&nbsp;
&lt;FilesMatch &quot;\.(ttf|otf)$&quot;&gt;
&lt;IfModule mod_headers.c&gt;
Header set Access-Control-Allow-Origin &quot;*&quot;
&lt;/IfModule&gt;
&lt;/FilesMatch&gt;</pre></div></div>

<p>With this HTTP header enabled, any page can access the fonts on this site, not just pages from the same site. </p>
<p><strong>Font Licensing Issues</strong></p>
<p>When using a font for a website, it&#8217;s important to always confirm that the font license permits use on a website. If the license agreement is filled with opaque legalese, err on the side of caution and check with the font vendor before using a font on a site. If the license permits its use, it&#8217;s a good idea to add a comment near the @font-face rules that points to the license, for future reference.</p>
<p><em>“I found a free font, can I use it on my site?”</em></p>
<p>Maybe, maybe not. Some free fonts are distributed as teaser products to encourage a purchase and don&#8217;t allow for redistribution or posting on a web server. Check the license, even for free fonts.</p>
<p><em>“I just want to use [insert favorite font name here] on my site. Is that possible?”</em></p>
<p>Right now, probably not. The use of font linking on the web is still in its infancy. Most fonts that ship with proprietary OS&#8217;s today have licenses that limit their use to standard desktop applications, so uploading these fonts to a web server is almost certainly not permitted. Piracy has plagued the font industry in the past, so most font vendors are wary of allowing their fonts to be used except in relatively limited contexts. Many font vendors are focused on the needs of publishing and printing industries, and the relative complexity of their license agreements often reflects this. In the future, some font designers may conclude that the sales of fonts as web fonts will outweigh any potential loss in sales due to piracy, others may not. Their license agreements will reflect this choice and should be respected.</p>
<p>The stock photography market is often described as a $2 billion market but the web font market is still close to a $0 market, it can only go up! </p>
<p><strong>Font Linking In Internet Explorer</strong></p>
<p>Font linking has been possible with Internet Explorer but only for linking to fonts in the proprietary EOT font format. The only way to create EOT fonts is to use the <a href="http://www.microsoft.com/typography/WEFT.mspx">Microsoft WEFT tool</a>, available only on Windows. Only TrueType and OpenType TT fonts can be converted to EOT format, OpenType PS (.otf) fonts cannot be used.</p>
<p>Internet Explorer only recognizes the <em>font-family</em> and <em>src</em> descriptors within @font-face rules, so each family can only contain a single face. It doesn&#8217;t understand <em>format()</em> hints and will ignore any @font-face rule containing these hints. This behavior can be used enable font linking cross platform:</p>

<div class="wp_syntax"><div class="code"><pre class="css" style="font-family:monospace;"><span style="color: #808080; font-style: italic;">/* Font definition for Internet Explorer */</span>
<span style="color: #808080; font-style: italic;">/*         (*must* be first)             */</span>
<span style="color: #a1a100;">@font-face {</span>
  <span style="color: #000000; font-weight: bold;">font-family</span><span style="color: #00AA00;">:</span> Gentium<span style="color: #00AA00;">;</span>
  src<span style="color: #00AA00;">:</span> <span style="color: #993333;">url</span><span style="color: #00AA00;">&#40;</span><span style="color: #ff0000; font-style: italic;">Gentium.eot</span><span style="color: #00AA00;">&#41;</span> <span style="color: #808080; font-style: italic;">/* can't use format() */</span><span style="color: #00AA00;">;</span>
<span style="color: #00AA00;">&#125;</span>
&nbsp;
<span style="color: #808080; font-style: italic;">/* Font definition for other browsers */</span>
<span style="color: #a1a100;">@font-face {</span>
  <span style="color: #000000; font-weight: bold;">font-family</span><span style="color: #00AA00;">:</span> Gentium<span style="color: #00AA00;">;</span>
  src<span style="color: #00AA00;">:</span> <span style="color: #993333;">url</span><span style="color: #00AA00;">&#40;</span><span style="color: #ff0000; font-style: italic;">Gentium.ttf</span><span style="color: #00AA00;">&#41;</span> format<span style="color: #00AA00;">&#40;</span><span style="color: #ff0000;">&quot;opentype&quot;</span><span style="color: #00AA00;">&#41;</span><span style="color: #00AA00;">;</span>
<span style="color: #00AA00;">&#125;</span></pre></div></div>

<p><strong>Future Work</strong></p>
<p>For Firefox 3.5, the <a href="https://bugzilla.mozilla.org/show_bug.cgi?id=3512"><em>font-stretch</em></a> and <a href="https://bugzilla.mozilla.org/show_bug.cgi?id=475891"> <em>unicode-range</em></a> descriptors are not supported.  <a href="https://bugzilla.mozilla.org/show_bug.cgi?id=119490">Fonts defined in SVG documents</a> are also not supported yet.  These are under consideration for inclusion in future releases.  As always, patches are welcome!</p>
<p><strong>Further Resources</strong></p>
<p><strong>Translations</strong></p>
<ul>
<li><a href="http://www.fatcow.com/edu/beautiful-fonts-with-font-face-be/">Belorussian translation</a>
</ul>
<p><strong>Documentation</strong></p>
<ul>
<li><a href="https://developer.mozilla.org/en/CSS/@font-face">MDC @font-face documentation</a>
<li><a href="http://www.w3.org/TR/2008/REC-CSS2-20080411/fonts.html">CSS2 Fonts specification</a>
<li><a href="http://dev.w3.org/csswg/css3-fonts/">CSS3 Fonts draft</a>
<li><a href="http://www.w3.org/TR/access-control/">Cross-Origin Resource Sharing Working Draft</a>
</ul>
<p><strong>Examples</strong></p>
<ul>
<li><a href="http://www.alistapart.com/articles/cssatten">CSS @ Ten: The Next Big Thing</a>
<li><a href="http://nicewebtype.com/fonts/graublau-sans-web/">Example layout using Graublau Sans</a>
<li><a href="http://typeinspire.com/">Examples of Interesting Web Typography</a>
<li><a href="http://webtypography.net/">The Elements of Typographic Style Applied to the Web</a>
</ul>
<p><strong>Font Resources</strong></p>
<ul>
<li><a href="http://www.fontsquirrel.com/">Font Squirrel</a>
<li><a href="http://opentype.info/demo/webfontdemo.html">10 Great Free Fonts for @font-face</a>
<li><a href="http://fonts.philip.html5.org/">Web-based font subsetting tool</a>
<li><a href="http://www.smashingmagazine.com/2007/11/08/40-excellent-freefonts-for-professional-design/">40 Excellent Free Fonts by Smashing Magazine</a>
<li><a href="http://sourceforge.net/projects/fonttools/">FontTools/TTX &#8211; Python scripts for displaying font data</a>
</ul>
<p><strong>Font Politics</strong></p>
<ul>
<li><a href="http://blogs.msdn.com/ie/archive/2008/07/21/font-embedding-on-the-web.aspx">Microsoft&#8217;s Bill Hill about Font Embedding</a>
<li><a href="http://cwilso.com/2008/07/23/fonts-embedding-vs-linking/">Microsoft&#8217;s Chris Wilson about direct linking to TrueType fonts</a>
<li><a href="http://weblogs.mozillazine.org/roc/archives/2008/08/the_coming_batt.html">Robert O&#8217;Callahan&#8217;s blog post on web font formats</a>
<li><a href="http://www.w3.org/Fonts/Misc/minutes-2008-10">Discussion of font formats at W3C TPAC meeting</a>
<li><a href="http://diveintomark.org/archives/2009/04/21/fuck-the-foundries">Mark Pilgrim&#8217;s post critical of font foundries</a>
<li><a href="http://dbaron.org/log/20090317-fonts">David Baron&#8217;s thoughts about downloadable font formats</a>
</ul>
]]></content:encoded>
			<wfw:commentRss>http://hacks.mozilla.org/2009/06/beautiful-fonts-with-font-face/feed/</wfw:commentRss>
		<slash:comments>176</slash:comments>
		</item>
	</channel>
</rss>

