<?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>User Agent Man &#187; Fonts</title>
	<atom:link href="http://www.useragentman.com/blog/category/technologies/fonts/feed/" rel="self" type="application/rss+xml" />
	<link>http://www.useragentman.com/blog</link>
	<description>A Blog about Client Side Web Technology</description>
	<lastBuildDate>Thu, 26 Jan 2012 03:14:32 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.2.1</generator>
		<item>
		<title>Installing Cygwin and FontForge for Windows</title>
		<link>http://www.useragentman.com/blog/2011/02/27/installing-cygwin-and-fontforge-for-windows/</link>
		<comments>http://www.useragentman.com/blog/2011/02/27/installing-cygwin-and-fontforge-for-windows/#comments</comments>
		<pubDate>Sun, 27 Feb 2011 20:25:20 +0000</pubDate>
		<dc:creator>zoltan</dc:creator>
				<category><![CDATA[@font-face]]></category>
		<category><![CDATA[converting]]></category>
		<category><![CDATA[Cygwin]]></category>
		<category><![CDATA[FontForge]]></category>
		<category><![CDATA[Fonts]]></category>

		<guid isPermaLink="false">http://www.useragentman.com/blog/?p=2339</guid>
		<description><![CDATA[<img src="/blog/wp-content/uploads/2011/02/fontforge.png" /> FontForge, as far as I can tell, is the best free font editing and conversion tool available for all operating systems.  The problem is, the average user may have difficulty getting it to work under Windows.  Because a lot of web designers out there may not be familiar with UNIX command shells and Cygwin, I have written this blog post to help. ]]></description>
			<content:encoded><![CDATA[<div class="importantNotes">
<h3>Note:</h3>
<p>This post is a companion to my article on <a href="http://www.useragentman.com/blog/?p=2275">Converting @font-face Fonts Quickly In Any OS</a>.</p>
</div>
<p><div id="attachment_2517" class="wp-caption alignleft" style="width: 260px"><a href="http://www.useragentman.com/blog/wp-content/uploads/2011/02/fontforge.png"><img src="http://www.useragentman.com/blog/wp-content/uploads/2011/02/fontforge.png" alt="" title="fontforge" width="250" height="141" class="size-full wp-image-2517" /></a><p class="wp-caption-text">FontForge is a great font editor, but it can be a pain to install for Windows users. Hopefully this article will help you.</p></div> FontForge, as far as I can tell, is the best free font editing and conversion tool available for all operating systems.  Web developers edit images and photographs with tools like The Gimp and Photoshop, so why can&#8217;t we edit fonts?  The problem is FontForge was originally a UNIX X-Windows application, and the average user may have difficulty getting it to work under Windows. Since a lot of web designers out there may not be familiar with UNIX command shells and Cygwin, I have written this blog post to help.  If you find any errors, please let me know in the comments section below &mdash; I do want to make this as easy and as painless as I possibly can. </p>
<h2>Step 1: Install Cygwin</h2>
<p>First thing you must do in order to run FontForge under Windows is to install Cygwin.  Cygwin is a way to allow programs that run under the Linux Operating System to compile under Windows.  <strong>Do not worry &#8230; we are not going to compile any source code.</strong> FontForge has already been compiled under Cygwin and has been packaged up so that end users don&#8217;t have to.  But in order to use it, you must install Cygwin first:</p>

<p>Cygwin has a nice setup program that downloads and
        installs the necessary Cygwin packages for you.</p>

        <ol type="1">
            <li>
                <p>Open the Cygwin, <a href="http://cygwin.com/"
                target="_top">http://cygwin.com/</a> page in your
                web browser</p>
            </li>

            <li>
                <p>Click on the <a href=
                "http://cygwin.com/setup.exe" target=
                "_top">&#13;<span class=
                "QUOTE">"setup.exe"</span></a> link. This link
                downloads <tt class="filename">setup.exe</tt> from
                the primary Cygwin server; save <tt class=
                "filename">setup.exe</tt> to the directory that you
                would like to store the downloaded packages in
                (e.g. <tt class="filename">c:\download</tt>); do
                not save <tt class="filename">setup.exe</tt> to <tt
                class="filename">c:\cygwin</tt>, as that is the
                default directory for the extraction and
                installation of the downloaded packages.</p>
            </li>

            <li>
                <p>Run <tt class="filename">setup.exe</tt>, you
                will see the welcome screen:</p>

                <div class="mediaobject">
                    <p><img alt="" src=
                    "/blog/wp-content/uploads/2011/02/cyi01welcome.png"></p>
                </div>
            </li>

            <li>
                <p>Click <span class="guibutton">Next</span> to
                proceed to the next screen.</p>
            </li>

            <li>
                <p>Choose, <span class="guilabel">Install from
                Internet</span>, this will still save the package
                files to your download directory so that you can
                install Cygwin on any number of machines:</p>

                <div class="mediaobject">
                    <p><img alt="" src=
                    "/blog/wp-content/uploads/2011/02/cyi02installoption.png"></p>
                </div>
            </li>

            <li>
                <p>Click <span class="guibutton">Next</span> to
                proceed to the next screen.</p>
            </li>

            <li>
                <p>The default <span class="guilabel">Install
                Root</span> is <tt class="filename">c:\cygwin</tt>
                which should be fine for most installations. Leave
                <span class="guilabel">Default Text File
                Type</span> as <acronym class=
                "acronym">UNIX</acronym>. Leave <span class=
                "guilabel">Install For</span> set to <span class=
                "guilabel">All</span> unless you lack local
                administrative privileges.</p>

                <div class="mediaobject">
                    <p><img alt="" src=
                    "/blog/wp-content/uploads/2011/02/cyi03installto.png"></p>
                </div>
            </li>

            <li>
                <p>Click <span class="guibutton">Next</span> to
                proceed to the next screen.</p>
            </li>

            <li>
                <p><span class="guilabel">Local Package
                Directory</span> should default to the directory
                that you ran <tt class="filename">setup.exe</tt>
                from:</p>

                <div class="mediaobject">
                    <p><img alt="" src=
                    "/blog/wp-content/uploads/2011/02/cyi04directory.png"></p>
                </div>
            </li>

            <li>
                <p>Click <span class="guibutton">Next</span> to
                proceed to the next screen.</p>
            </li>

            <li>
                <p>Choose your proxy setup, or, just choose <span
                class="guilabel">Direct Connection</span> if no
                proxy is needed:</p>

                <div class="mediaobject">
                    <p><img alt="" src=
                    "/blog/wp-content/uploads/2011/02/cyi05proxy.png"></p>
                </div>
            </li>

            <li>
                <p>Click <span class="guibutton">Next</span> to
                proceed to the next screen.</p>
            </li>

            <li>
                <p>Select your nearest mirror for downloading:</p>

                <div class="mediaobject">
                    <p><img alt="" src=
                    "/blog/wp-content/uploads/2011/02/cyi06mirror.png"></p>
                </div>
            </li>

            <li>
                <p>Click <span class="guibutton">Next</span> to
                proceed to the next screen; setup will download a
                list of available packages as it moves to the next
                screen.</p>
            </li>

            <li>
                <p>On the next screen you will select the packages
                that will be downloaded and installed. A listing of
                the packages you will need is given below:</p>

                <ul>
                <li>Under the <tt class=
                "literal">X11</tt> category, install:</li>

                <ul type="a">

                <li>
                        <p><tt class=
                        "filename">X-start-menu-icons</tt>
                        (optional but recommended, adds icons for X Clients to the
                        Start menu)</p>
                    </li>
                    
                    <li>
                        <p><tt class="filename">xinit</tt>
                        (required, scripts for starting the X
                        server: <b class="command">xinit</b>, <b
                        class="command">startx</b>, <b class=
                        "command">startwin</b> (and a shortcut on
                        the Start Menu to run it), <b class=
                        "command">startxdmcp.bat</b> )</p>
                    </li>

                    <li>
                        <p><tt class="filename">xorg-docs</tt>
                        (optional, <b class="command">man</b>
                        pages)</p>
                    </li>

                    <li>
                        <p><tt class="filename">xorg-server</tt>
                        (required, the Cygwin/X X Server)</p>
                    </li>

                    

                  
<!--
                    <li>
                        <p>You may also want to ensure that the <tt
                        class="literal">inetutils</tt> or <tt
                        class="literal">openssh</tt> packages are
                        selected if you wish to use <b class=
                        "command">telnet</b> or <b class=
                        "command">ssh</b> connections to run remote
                        X clients.</p>
                    </li>
-->
                </ul>
               </li>
               <li>Under the <strong>Graphics</strong> catagory, install the <code>giflib</code>, <code>libpng</code>, <code>jpeg</code> and <code>libtiff</code> packages (the latest non-beta version of <code>libtiff</code> at the time of this writing is <code>libtiff5</code>)</li>
               <li>Under <strong>Editors</strong>, install <code>vim</code>.</li>
               <li>Under <strong>Web</strong>, instal <code>wget</code></li>
               <li>Finally, install <code>rxvt</code> in the <strong>Shells</strong> category (just <code>rxvt</code>, not any of the <code>rxvt-unicode-*</code> packages)</li>
            </ul>


                <div class="mediaobject">
                    <p><img alt="" src=
                    "/blog/wp-content/uploads/2011/02/cyi07packages.png"></p>
                </div>
            </li>

            <li>
                <p>Click <span class="guibutton">Next</span> to
                begin the download process, you may want to try
                another mirror if you see a <span class=
                "QUOTE">"Connecting"</span> message on this screen
                for a long period of time:</p>

                <div class="mediaobject">
                    <p><img alt="" src=
                    "/blog/wp-content/uploads/2011/02/cyi08downloading.png"></p>
                </div>
            </li>

            <li>
                <p>After the packages are downloaded, setup will
                automatically begin to install them:</p>

                <div class="mediaobject">
                    <p><img alt="" src=
                    "/blog/wp-content/uploads/2011/02/cyi09installing.png"></p>
                </div>
            </li>

            <li>
                <p>I highly recommend allowing Cygwin Setup to
                create Desktop and Start Menu icons for you; these
                icons simply launch a <span class=
                "application">bash</span> shell:</p>

                <div class="mediaobject">
                    <p><img alt="" src=
                    "/blog/wp-content/uploads/2011/02/cyi10createicons.png"></p>
                </div>
            </li>

            <li>
                <p>Click <span class="guibutton">Finish</span> to
                close the setup program.</p>
            </li>
        </ol>



<h2>Step 2: Install FontForge</h2>

<p>Now that you have successfully installed Cygwin and the libraries necessary to run FontForge, it is now to time to install FontForge itself.  <strong>This part is not obvious</strong>, and is the main reason why I wrote these instructions.</p>

<p>There are two ways you can install FontForge: using the Cygwin setup program you just downloaded (not-so-easy) or using the "Unofficial Windows Port".</p>

<p>If you get stuck, there is more help available at the <a href="http://sourceware.org/cygwinports/">Official Cygwin Ports</a> page.</p>



<h3>Using the Cygwin Setup</h3>

<p>This is my preferred method for installing FontForge, but may not always be successful because the download process stalls sometimes. If it doesn't work the first time, quit the process and try again.  <strong>Note that I found that installing it this way works best at around 7:00 AM - 4:00 PM EST.</strong> I believe that this is because the Cygwin Ports server is busier at night, but I am just guessing.  Your results may vary.</p>

<p>If you get really frustrated installing it this way, try the <a href="#mingw">"Unofficial Windows Port"</a> method instead.</p>

<ol>
<li>Go to the directory you saved Cygwin's setup.exe when you installed Cygwin.</li>

<li>Right click on setup.exe and choose "Create Shortcut..."</li>

<li>Right click on the shortcut that you created and choose "Properties".  In the shortcut dialogue, change the Target field from <code>setup.exe</code> to <code>setup.exe -K http://cygwinports.org/ports.gpg</code>

<div class="mediaobject">
     <p><img alt="" src="/blog/wp-content/uploads/2011/02/ff01shortcut.png"></p>
</div>
</li>
<li>Double-click on the new shortcut. Go through the steps 3 - 12 of the installation instruction of Cygwin.</li>
<li>When you get to step 13, you must enter <code>ftp://ftp.cygwinports.org/pub/cygwinports</code>  into the <strong>User URL</strong> field and click <span class="guibutton">Add</span> button.  When you do, it will be added to the list of download sites. <strong>Ensure that the new site is the only one chosen</strong> (sometimes two will be chosen at this point, the one you just added and one you used to install Cygwin), and click <span class="guibutton">Next</span>.
<div class="mediaobject">
     <p><img alt="" src="/blog/wp-content/uploads/2011/02/ff02setupPause.png"></p>
</div>
Note that you will see this progress dialogue longer than you did in when installing Cygwin:

<div class="mediaobject">
     <p><img alt="" src="/blog/wp-content/uploads/2011/02/ff02setupPause.png"></p>
</div>
Be patient.  You should eventually get to the next dialogue. If it gives you an error about the version of setup.bz2 being earlier than the previous one or something similar, ignore it.
</li>
<li>At this point, the <strong>Select Packages</strong> will appear.  Go the <strong>Graphics</strong> 
category and choose <strong>fontforge</strong>:

<div class="mediaobject">
     <p><img alt="" src="/blog/wp-content/uploads/2011/02/ff03chooseFontForge.png"></p>
</div>
Click <span class="guibutton">Next</span>.</li>

<li> You will see a dialogue similar to this:
<div class="mediaobject">
     <p><img alt="" src="/blog/wp-content/uploads/2011/02/ff04resolveDependencies.png"></p>
</div>
This is just showing you it has to download the fontforge's dependencies as well. Just click <span class="guibutton">Next</span></li>
<li>You will see the download dialogue:
<div class="mediaobject">
     <p><img alt="" src="/blog/wp-content/uploads/2011/02/ff05progress.png"></p>
</div>

This is the part that may take a long time to run, and may even stall.  Let it run for a while.  If it gets stuck for a long time, you may want to choose a different mirror.
</li>
<li>
If you complete the install process, you should now have successfully installed fontforge.  To test your install, do the following:

<ul>
<li>Go to the Start Menu, choose "Programs" and in the "Cygwin" Program Group, launch <code>rxvt-native</code>.

<a href="http://www.useragentman.com/blog/wp-content/uploads/2011/02/rxvtLaunch.png"><img src="http://www.useragentman.com/blog/wp-content/uploads/2011/02/rxvtLaunch.png" alt="Screenshot of how to launch rxvt under Windows XP" title="rxvtLaunch" width="672" height="302" class="aligncenter size-full wp-image-2464" /></a></li>



<li>
From the command line, enter the <code>startxwin</code> command.   You should see the following output

<blockquote class="code">
<pre>
Welcome to the XWin X Server
Vendor: The Cygwin/X Project
Release: 1.9.4.0 (10904000)
Package version 1.9.4-1 built 2011-02-07

XWin was started with the following command line:

X :0 -multiwindow 

_XSERVTransSocketOpenCOTSServer: Unable to open socket for inet6
_XSERVTransOpen: transport open failed for inet6/NB07023:0
_XSERVTransMakeAllCOTSServerListeners: failed to open listener for inet6
winInitializeScreens - 1
winInitializeScreen - 0
(II) xorg.conf is not supported
(II) See http://x.cygwin.com/docs/faq/cygwin-x-faq.html for more information
LoadPreferences: /home/haw5855/.XWinrc not found
LoadPreferences: Loading /etc/X11/system.XWinrc
LoadPreferences: Done parsing the configuration file...
winGetDisplay: DISPLAY=:0.0
winDetectSupportedEngines - Windows NT/2000/XP
winDetectSupportedEngines - DirectDraw installed
winDetectSupportedEngines - Allowing PrimaryDD
winDetectSupportedEngines - DirectDraw4 installed
winDetectSupportedEngines - Returning, supported engines 0000001f
winSetEngine - Multi Window or Rootless =&gt; ShadowGDI
winScreenInit - Using Windows display depth of 32 bits per pixel
winAllocateFBShadowGDI - Creating DIB with width: 1280 height: 800 depth: 32
winFinishScreenInitFB - Masks: 00ff0000 0000ff00 000000ff
winInitVisualsShadowGDI - Masks 00ff0000 0000ff00 000000ff BPRGB 8 d 24 bpp 32
null screen fn ReparentWindow
null screen fn RestackWindow
InitQueue - Calling pthread_mutex_init
InitQueue - pthread_mutex_init returned
InitQueue - Calling pthread_cond_init
InitQueue - pthread_cond_init returned
winInitMultiWindowWM - Hello
winInitMultiWindowWM - Calling pthread_mutex_lock ()
winMultiWindowXMsgProc - Hello
Screen 0 added at virtual desktop coordinate (0,0).
winMultiWindowXMsgProc - Calling pthread_mutex_lock ()
MIT-SHM extension disabled due to lack of kernel support
XFree86-Bigfont extension local-client optimization disabled due to lack of shared memory support in the kernel
(II) AIGLX: Loaded and initialized /usr/lib/dri/swrast_dri.so
(II) GLX: Initialized DRISWRAST GL provider for screen 0
winPointerWarpCursor - Discarding first warp: 640 400
(--) 3 mouse buttons found
(--) Setting autorepeat to delay=500, rate=31
(--) Windows keyboard layout: "00000409" (00000409) "US", type 4
(--) Found matching XKB configuration "English (USA)"
(--) Model = "pc105" Layout = "us" Variant = "none" Options = "none"
Rules = "base" Model = "pc105" Layout = "us" Variant = "none" Options = "none"
winInitMultiWindowWM - pthread_mutex_lock () returned.
winMultiWindowXMsgProc - pthread_mutex_lock () returned.
winMultiWindowXMsgProc - pthread_mutex_unlock () returned.
winGetDisplay: DISPLAY=:0.0
winMultiWindowXMsgProc - DISPLAY=:0.0
winInitMultiWindowWM - pthread_mutex_unlock () returned.
winProcEstablishConnection - Hello
winInitClipboard ()
winClipboardProc - Hello
DetectUnicodeSupport - Windows NT/2000/XP
winProcEstablishConnection - winInitClipboard returned.
winGetDisplay: DISPLAY=:0.0
winInitMultiWindowWM - DISPLAY=:0.0
winGetDisplay: DISPLAY=:0.0
winClipboardProc - DISPLAY=:0.0
winMultiWindowXMsgProc - XOpenDisplay () returned and successfully opened the display.
winInitMultiWindowWM - XOpenDisplay () returned and successfully opened the display.
winClipboardProc - XOpenDisplay () returned and successfully opened the display.
</pre>
</blockquote>

You should see the XWindows icon <img class="inline" src="http://www.useragentman.com/blog/wp-content/uploads/2011/02/xwinTray.png" alt="" title="xwinTray"  /> in the tray .</li>

<li>Next enter the command <code>fontforge &</code> (include the <code>&</code> if you want to run <code>fontforge</code> in the background so that you can enter in other commands into <code>rxvt</code> later).  You will see the fontforge splash screen as well as a file dialogue box.
<div id="attachment_2472" class="wp-caption aligncenter" style="width: 310px"><a href="http://www.useragentman.com/blog/wp-content/uploads/2011/02/fontforgesplash.png"><img src="http://www.useragentman.com/blog/wp-content/uploads/2011/02/fontforgesplash-300x204.png" alt="The FontForge Splash Screen with File Dialogue" title="fontforgesplash" width="300" height="204" class="size-medium wp-image-2472" /></a><p class="wp-caption-text">The FontForge Splash Screen with File Dialogue</p></div>

If this is what you see, then congratulations, you installed it correctly!</li>

<li>If you get an error similar to <code>"error while loading shared libraries: ?: cannot open shared object file"</code>, then you forgot to install one of the dependencies.  You can find out which one is missing by entering in the command <code>cygcheck fontforge</code>.  You should see output similar to this:

<blockquote class="code">
<pre>
$ cygcheck fontforge
Found: C:\cygwin\bin\fontforge.exe
Found: C:\cygwin\bin\fontforge.exe
C:\cygwin\bin\fontforge.exe
  C:\cygwin\bin\cygfontforge-1.dll
    C:\cygwin\bin\cyggutils-1.dll
      C:\cygwin\bin\cyggunicode-3.dll
        C:\cygwin\bin\cygwin1.dll
          C:\Windows\system32\ADVAPI32.DLL
            C:\Windows\system32\msvcrt.dll
              C:\Windows\system32\KERNELBASE.dll
                C:\Windows\system32\ntdll.dll
              C:\Windows\system32\API-MS-Win-Core-Console-L1-1-0.dll
              C:\Windows\system32\API-MS-Win-Core-DateTime-L1-1-0.dll
              C:\Windows\system32\API-MS-Win-Core-Debug-L1-1-0.dll
              C:\Windows\system32\API-MS-Win-Core-ErrorHandling-L1-1-0.dll
              C:\Windows\system32\API-MS-Win-Core-Fibers-L1-1-0.dll
              C:\Windows\system32\API-MS-Win-Core-File-L1-1-0.dll
              C:\Windows\system32\API-MS-Win-Core-Handle-L1-1-0.dll
              C:\Windows\system32\API-MS-Win-Core-Heap-L1-1-0.dll
              C:\Windows\system32\API-MS-Win-Core-Interlocked-L1-1-0.dll
              C:\Windows\system32\API-MS-Win-Core-Localization-L1-1-0.dll
              C:\Windows\system32\API-MS-Win-Core-LibraryLoader-L1-1-0.dll
              C:\Windows\system32\API-MS-Win-Core-Memory-L1-1-0.dll
              C:\Windows\system32\API-MS-Win-Core-Misc-L1-1-0.dll
              C:\Windows\system32\API-MS-Win-Core-NamedPipe-L1-1-0.dll
              C:\Windows\system32\API-MS-Win-Core-ProcessEnvironment-L1-1-0.dll
              C:\Windows\system32\API-MS-Win-Core-ProcessThreads-L1-1-0.dll
              C:\Windows\system32\API-MS-Win-Core-Profile-L1-1-0.dll
              C:\Windows\system32\API-MS-Win-Core-String-L1-1-0.dll
              C:\Windows\system32\API-MS-Win-Core-Synch-L1-1-0.dll
              C:\Windows\system32\API-MS-Win-Core-SysInfo-L1-1-0.dll
              C:\Windows\system32\API-MS-Win-Core-Util-L1-1-0.dll
            C:\Windows\system32\API-MS-WIN-Service-Core-L1-1-0.dll
            C:\Windows\system32\API-MS-WIN-Service-winsvc-L1-1-0.dll
            C:\Windows\system32\API-MS-WIN-Service-Management-L1-1-0.dll
            C:\Windows\system32\API-MS-WIN-Service-Management-L2-1-0.dll
            C:\Windows\system32\API-MS-Win-Core-LocalRegistry-L1-1-0.dll
            C:\Windows\system32\API-MS-Win-Security-Base-L1-1-0.dll
            C:\Windows\system32\KERNEL32.dll
              C:\Windows\system32\API-MS-Win-Core-RtlSupport-L1-1-0.dll
              C:\Windows\system32\API-MS-Win-Core-IO-L1-1-0.dll
              C:\Windows\system32\API-MS-Win-Core-ThreadPool-L1-1-0.dll
            C:\Windows\system32\RPCRT4.dll
              C:\Windows\system32\API-MS-Win-Core-DelayLoad-L1-1-0.dll
        C:\cygwin\bin\cyggcc_s-1.dll
        C:\cygwin\bin\cygiconv-2.dll
      C:\cygwin\bin\cygintl-8.dll
      C:\cygwin\bin\cygpng12.dll
        C:\cygwin\bin\cygz.dll
    C:\cygwin\bin\cygfreetype-6.dll
    C:\cygwin\bin\cygspiro-0.dll
    C:\cygwin\bin\cyguninameslist-0.dll
    C:\cygwin\bin\cygxml2-2.dll
    C:\cygwin\bin\libpython2.6.dll
  C:\cygwin\bin\cyggdraw-4.dll
    C:\cygwin\bin\cygX11-6.dll
      C:\cygwin\bin\cygxcb-1.dll
        C:\cygwin\bin\cygXau-6.dll
        C:\cygwin\bin\cygXdmcp-6.dll
    C:\cygwin\bin\cygXft-2.dll
      C:\cygwin\bin\cygXrender-1.dll
      C:\cygwin\bin\cygfontconfig-1.dll
        C:\cygwin\bin\cygexpat-1.dll
    C:\cygwin\bin\cygXi-6.dll
      C:\cygwin\bin\cygXext-6.dll
    C:\cygwin\bin\cygcairo-2.dll
      C:\cygwin\bin\cygglitz-1.dll
      C:\cygwin\bin\cygpixman-1-0.dll
      C:\cygwin\bin\cygxcb-render-util-0.dll
        C:\cygwin\bin\cygxcb-render-0.dll
    C:\cygwin\bin\cygpango-1.0-0.dll
      C:\cygwin\bin\cygglib-2.0-0.dll
        C:\cygwin\bin\cygpcre-0.dll
      C:\cygwin\bin\cyggmodule-2.0-0.dll
      C:\cygwin\bin\cyggobject-2.0-0.dll
        C:\cygwin\bin\cyggthread-2.0-0.dll
    C:\cygwin\bin\cygpangocairo-1.0-0.dll
      C:\cygwin\bin\cygpangoft2-1.0-0.dll
    C:\cygwin\bin\cygpangoxft-1.0-0.dll
cygcheck: track_down: could not find cyggif-4.dll

cygcheck: track_down: could not find cygjpeg-7.dll

cygcheck: track_down: could not find cygtiff-5.dll
</pre>
</blockquote>

In this case, the missing libraries are <code>libgif</code>, <code>jpeg</code> and <code>libtiff</code>.  Go back to step 1 and ensure that you install them (Cygwin's setup will allow you to install them, even after you did the first install).</li>
</ol>

<h3 name="mingw" id="mingw">Using "unofficial fontforge-mingw"</h3>

<p><strike>A Japanese developer has posted a <a href="http://www.mingw.org/">MingW</a> port</strike>.  This developer of the mingw port has recently made a standalone version of the Cygwin version of fontforge available as well, and I encourage you to download the Cygwin one instead of the MingW one, since it seems to be a bit more up-to-date.  Both of these ports are available on the developer's <a href="http://www.geocities.jp/meir000/fontforge/">Geocities Japan</a> site (yes folks ... you read that right.  Geocities <strong>still</strong> exists in Japan!)  It is dead simple to install fontforge using this package:</p>


<ol>
<li>Download the package from <a href="http://www.geocities.jp/meir000/fontforge/">the project's homepage</a>.  Even though the page is in Japanese, the Dowload link is in English. :-)</li>
<li>unzip the package</li>
<li>To test if the installation was successful, go into the directory that contains the package and run the <code>fontforge.bat</code> batch file.</li>
</ol>

<div class="importantNotes">
<h3>Note:</h3>
By default, this program will run with a Japanese version of the user interface. In order to ensure it runs as English, you will need to edit the <code>fontforge.bat</code> and delete the following line:
<blockquote>
<code>
<br />
set LANG=ja_JP.UTF-8
<br />
<br />
</code>
</blockquote>

Thanks to <strong>Senne</strong> for leaving this tip in the comments below.
</div>

<p>Even thought this method doesn't really need the fullblown version of Cygwin (since it is designed to be standalone), I suggest installing Cygwin in order to use the <a href="/blog/?p=2275">the CSS3 Font Converter</a>.</p>


<h2>Futher Reading</h2>
<ul>
<li><a href="http://www.cygwin.com/cygwin-ug-net/">Cygwin User's Guide</a></li>
<li><a href="http://lifehacker.com/#!5633909/who-needs-a-mouse-learn-to-use-the-command-line-for-almost-anything">A Command Line Primer for Beginners</a></li>
</ul>

<h2>Copyright Notice</h2>
 
<p>Some of the contents of this post have been taken from the <a href="http://x.cygwin.com/docs/ug/cygwin-x-ug.html">Cygwin/X User's Guide</a>, copyright &copy; 2000 Harold L Hunt II and copyright &copy; 2009, 2010, 2011 Jon Turney. As per that document's license, permission is granted to copy, distribute and/or modify this document under the terms of the <a href="http://www.gnu.org/licenses/fdl-1.1.html">GNU Free Documentation License</a>, Version 1.1 or any later version published by the Free Software Foundation; with no Invariant Sections, with no Front-Cover Texts, and with no Back-Cover Texts.</p>

        
]]></content:encoded>
			<wfw:commentRss>http://www.useragentman.com/blog/2011/02/27/installing-cygwin-and-fontforge-for-windows/feed/</wfw:commentRss>
		<slash:comments>35</slash:comments>
		</item>
		<item>
		<title>Converting @font-face Fonts Quickly In Any OS</title>
		<link>http://www.useragentman.com/blog/2011/02/20/converting-font-face-fonts-quickly-in-any-os/</link>
		<comments>http://www.useragentman.com/blog/2011/02/20/converting-font-face-fonts-quickly-in-any-os/#comments</comments>
		<pubDate>Sun, 20 Feb 2011 22:00:00 +0000</pubDate>
		<dc:creator>zoltan</dc:creator>
				<category><![CDATA[@font-face]]></category>
		<category><![CDATA[converting]]></category>
		<category><![CDATA[CSS]]></category>
		<category><![CDATA[CSS3]]></category>
		<category><![CDATA[Cygwin]]></category>
		<category><![CDATA[FontForge]]></category>
		<category><![CDATA[Fonts]]></category>

		<guid isPermaLink="false">http://www.useragentman.com/blog/?p=2275</guid>
		<description><![CDATA[<img src="/blog/wp-content/uploads/2011/02/fontConvertSmall.jpg" /> I love experimenting with web fonts, but using the hodgepodge of free and open source desktop tools to convert them manually is time consuming. This inspired me to write a command line tool that would convert them all at once and create the CSS code like <a href="http://www.fontsquirrel.com/">Font Squirrel's generator</a>.  The result is a <a href="http://en.wikipedia.org/wiki/Shell_script">shell script</a> that uses <a href="http://fontforge.sourceforge.net/">FontForge</a>, <a href="http://xmlgraphics.apache.org/batik/">Batik</a> and <a href="http://readableweb.com/">Readable Web's</a> <a href="http://eotfast.com/">EOTFast</a> to do the heavy lifting.]]></description>
			<content:encoded><![CDATA[<p><div id="attachment_2315" class="wp-caption alignleft" style="width: 260px"><a href="http://www.useragentman.com/blog/wp-content/uploads/2011/02/fontConvert.jpg"><img src="http://www.useragentman.com/blog/wp-content/uploads/2011/02/fontConvert.jpg" alt="" title="fontConvert" width="250" height="307" class="size-full wp-image-2315" /></a><p class="wp-caption-text">Converting fonts quickly will help speed up production of your projects and can easily integrate into your workflow.</p></div></p>
<p>I love experimenting with web fonts, but using the hodgepodge of free and open source desktop tools to convert them manually is time consuming.  To speed things up a bit, <a href="http://www.fontsquirrel.com/">Font Squirrel</a> created the excellent <a href="http://www.fontsquirrel.com/fontface/generator">@Font-Face Generator</a> web application which not only generates the fonts for you, but also creates a stylesheet a developer can import and use the font immediately.  I really like this tool and it inspired me to write <strong>a command line tool that would create a package like Font Squirrel&#8217;s generator,</strong>  The result is a <a href="http://en.wikipedia.org/wiki/Shell_script">shell script</a> that uses <a href="http://fontforge.sourceforge.net/">FontForge</a>, <a href="http://xmlgraphics.apache.org/batik/">Batik</a> and <a href="http://readableweb.com/">Readable Web&#8217;s</a> <a href="http://eotfast.com/">EOTFast</a> to do the heavy lifting.  It was originally developed under Windows using <a href="http://www.cygwin.com">Cygwin</a>, but I spent a bit of extra time to ensure that it can run under Linux and Mac OS X (using <a href="http://code.google.com/p/ttf2eot/">ttf2eot</a> instead of the Windows-only EOTFast to generate the <code>.eot</code> fonts).  Since it runs on OS X, it should run under BSD flavours of Unix as well, but I haven&#8217;t confirmed this (I would be grateful to hear from any BSD users on how it works).</p>
<p>This tool is not intended to replace Font Squirrel&#8217;s tool (as a matter of fact, their tool has a few more options than mine).  However, I find it useful when trying out a variety of fonts on my local web server, so I thought I&#8217;d share.  </p>
<p><strong>If you&#8217;re not familiar with the command line</strong> on your particular operating system, this may not be the solution for you. I will, however, give step-by-step instructions on how to install and run the shell script. <strong> If you stumble into any problems</strong>, and especially if <strong>you find any inaccuracies</strong> with the instructions here, please post a comment below and I will try my best to address them.  I find this script quite useful and would love to help the rest of The Community&trade; as much I can if they would like to use it as well.</p>
<p><a href="https://github.com/zoltan-dulac/css3FontConverter" class="exampleLink">Download the CSS3 Font Converter from GitHub</a></p>
<h2>Examples</h2>
<p>Before we start using the tool, I have included a few examples.  They are intended to show situations where a developer may not want to use fonts that are not included on your computer&#8217;s font-stack.</p>
<table class="dataTable">
<thead>
<tr>
<th>Argor Biw Scaqh/Old London</th>
<th>Peanuts</th>
<th>Aaaaight!!!!!</th>
</tr>
</thead>
<tbody>
<tr>
<td><a href="/tests/fontConverter/ArgBiwSc.html"><img src="http://www.useragentman.com/blog/wp-content/uploads/2011/02/argor.png" alt="Screenshot of my Argor Biw Scaqh/Old London example" title="argor"  class="alignnone size-full wp-image-2321" /></a></p>
<p>Serif or Sans-serif? How about neither? This example makes heavy use of <a href="http://en.wikipedia.org/wiki/Blackletter">Black Letter</a> fonts, which are not included in most operating systems today.</p>
</td>
<td><a href="/tests/fontConverter/peanuts.html"><img src="http://www.useragentman.com/blog/wp-content/uploads/2011/02/peanuts.png" alt="Screenshot of Peanuts font example." title="peanuts" class="alignnone size-full wp-image-2323" /></a></p>
<p>Why use <a href="http://www.bbc.co.uk/news/magazine-11582548">a font everybody seems to hate</a> when there are other cartoony fonts to choose from?</td>
<td><a href="/tests/fontConverter/aaaiight.html"><img src="http://www.useragentman.com/blog/wp-content/uploads/2011/02/aaaaight.png" alt="Screenshot of Aaaaight!!!!! example page." title="aaaaight" class="alignnone size-full wp-image-2325" /></a></p>
<p>Grafitti style fonts have a unique look all their own.</p>
</td>
</tbody>
</table>
<p>In all cases, the original fonts were in True Type format. The font-converter then converted the fonts into all the other @font-face formats, and created a style sheet containing the appropriate @font-face rules that can be easily imported by the author.</p>
<h2>Usage</h2>
<p>You can convert as many <code>.ttf</code> or <code>.otf</code> fonts in a directory by using the following command:</p>
<blockquote class="code">
<pre>
convertFonts.sh &lt;filelist&gt;
</pre>
</blockquote>
<p>For example, if you wanted to convert all the <code>.ttf</code> files in the directory you are in, you could type in the command:</p>
<blockquote class="code">
<pre>
$ convertFonts.sh *.ttf
</pre>
</blockquote>
<p>The fonts will then be converted to the <code>.eot</code>, <code>.woff</code>, and <code>.svg</code> formats.  It will also generate a stylesheet, <code>stylesheet.css</code>, that will produce the <code>@font-face</code> rules using <a href="http://www.fontspring.com/blog/the-new-bulletproof-font-face-syntax">The New Bulletproof @Font-Face Syntax</a>.</p>
<p>If you are converting <code>.otf</code> fonts, a <code>.ttf</code> font will be generated first before the other fonts. </p>
<h2>Installation</h2>
<p>I have tried to make this tool as easy to use as possible.  If you follow these easy steps, it should work.  If you have trouble installing the tool after you have followed all these steps, please leave a comment at the end of this post &mdash; I really want to make this as bulletproof as possible.</p>
<ol>
<li><strong>If you are using Windows XP/Vista/7, install <a href="http://www.cygwin.com">Cygwin</a> with the FontForge package</strong>. If you have never done this before, <a href="http://www.useragentman.com/blog/?p=2339">I have created a supplementary blog post to walk you through the installation process</a>.  If you have installed Cygwin before, you still may want to read the last half of the article, since installing FontForge can be difficult under Cygwin (at least it was for me until I did some digging).</li>
<li><strong>Download and Install <a href="http://fontforge.sourceforge.net/">FontForge</a> </strong>(if you are a Windows user, this is covered in step one). There are complete instructions on how to do this under <a href="http://fontforge.sourceforge.net/mac-install.html">OS X</a>, and <a href="http://fontforge.sourceforge.net/nix-install.html">Linux</a> as well.  <strong>Update (May 14, 2011):</strong> The Linux page doesn&#8217;t mention this, but if you are an Ubuntu user, you can use <code>apt-get</code> to do the installation for you easily:<br />
<blockquote class="code">
<pre>
sudo apt-get install fontforge
</pre>
</blockquote>
<p>Thanks to Richard Curran for pointing this out.</li>
<li><strong>If you don&#8217;t have it already, <a href="http://www.java.com/en/download/manual.jsp">install Java</a></strong> (it is required for Batik). If you are not sure how to do this, there are installation instuctions available for <a href="http://www.java.com/en/download/help/windows_manual_download.xml">Windows</a>, <a href="http://developer.apple.com/java/faq/">OS X</a>, and <a href="http://www.clickonf5.org/linux/how-install-sun-java-ubuntu-1004-lts/7777">Ubuntu Linux</a>).</li>
<li><strong><a href="http://xmlgraphics.apache.org/batik/download.cgi">Download the latest version of Batik</a>.</strong>  Make sure you remember where you unpack the archive &mdash; you&#8217;ll need this later.</li>
<li><strong>Download <a href="http://eotfast.com/">EOTFast</a></strong> (if you develop using Windows) <strong>or  <a href="http://code.google.com/p/ttf2eot/">ttf2eot</a></strong> (for OS X and Linux, <a href="http://www.tips-tricks.net/tag/ttf2eot/">installation instructions are here</a>).  </li>
<li><strong>Download the <a href="http://people.mozilla.com/~jkew/woff/">sfnt2woff</a> package</strong> (this page has packages for Windows and OS X, as well as the source that one can compile for Linux).</li>
<li><strong>Download the <a href="/downloads/css3FontConverter.zip">CSS3 Font Converter</a></strong> and unpack the contents in your path someplace.</li>
<li><strong>Open up a terminal window</strong> (under Cygwin, that would be the either the &#8220;Cygwin Bash Shell&#8221;, or, better yet, &#8220;rxvt native&#8221; if you have that installed). Then, <code>cd</code> into the directory that you unpacked the CSS3 Font Converter, and edit <code>convertFonts.sh</code> (if you are using Windows, <strong>don&#8217;t use notepad to edit this file</strong>, since shell scripts don&#8217;t like to be saved as Windows text.  If you are familar with it, use <code>vim</code> instead).  You will need to edit the first few lines:<br />
<blockquote class="code">
<pre>
#!/bin/bash

#########################################################################
## CONFIGURATION AREA: This stuff is the only stuff you may need to     #
##                     change.                                          #
#########################################################################

# Linux and Mac users, this directory should be changed to be of this form:
# BATIK_DIR="/Users/webtest/src/batik".  Windows should use the form below.
<span class="hilite">BATIK_DIR='c:\Program Files\Batik\batik-1.7'</span>

# The path should contain the directories where EOTFAST-1.EXE, ttf2eot,
# fontforge, and all the scripts in the @Font-Face Contruction Set reside.
# Uncomment the line below with the right directories.  Remember the
# $PATH at the beginning of the string, or the script will forget what
# was originally in the PATH.
<span class="hilite"># PATH="$PATH:/some/directory:/some/other/directory/"</span>

....
</pre>
</blockquote>
<p>You have to change the value of <code>BATIK_DIR</code> to the directory that contains the Batik code (ensure that it includes the <code>batik-1.7</code> directory at the end). If you haven&#8217;t installed the other packages in directories in your PATH, you must uncomment the <code>PATH</code> line and edit it so that it contains them.
</li>
<li><strong>If all is well, you should now be ready to convert fonts.</strong>  To test, create a new directory, download and unpack the <a href="http://www.dafont.com/old-london.font">Old London Font from Dafont.com</a> into it, and execute the following command:<br />
<blockquote class="code">
<pre>
$ convertFonts.sh *.ttf
</pre>
</blockquote>
<p>If all is successful, you should see output similar to this:</p>
<blockquote class="code">
<pre>
Converting OldLondon to eot
(Using EOTFAST)
Converting font "Old London"
Successfully written "OldLondon.eot"
Converting OldLondon to svg
Converting OldLondon to woff
Converting OldLondonAlternate to eot
(Using EOTFAST)
Converting font "Old London Alternate"
Successfully written "OldLondonAlternate.eot"
Converting OldLondonAlternate to svg
Converting OldLondonAlternate to woff
Writing Stylesheet ...
Extracting SVG ID
Getting Font Name
Extracting SVG ID
Getting Font Name
DONE!
</pre>
</blockquote>
<p>Not only does it convert the TrueType font in all the web formats, it produces a nice style sheet you can<br />
link to:</p>
<blockquote class="code">
<pre>
@font-face {
        font-family: 'OldLondon';
        src: url('OldLondon.eot?') format('eot'),
             url('OldLondon.woff') format('woff'),
             url('OldLondon.ttf')  format('truetype'),
             url('OldLondon.svg#OldLondon') format('svg');
}

@font-face {
        font-family: 'OldLondonAlternate';
        src: url('OldLondonAlternate.eot?') format('eot'),
             url('OldLondonAlternate.woff') format('woff'),
             url('OldLondonAlternate.ttf')  format('truetype'),
             url('OldLondonAlternate.svg#OldLondonAlternate') format('svg');
}
</pre>
</blockquote>
</li>
</ol>
<h2>Notes</h2>
<ol>
<li><strong>FontForge can do way more than convert fonts.</strong>  It is primarily a <strong>font editor</strong>, and I have used it to add accents characters to fonts that don&#8217;t have them (a necessity if you are a Canadian web developer that occasionally has to work with French text).  Play around with it &#8211; it may become as important to you as your graphics editor and your IDE.</li>
<li><strong>The script will use EOTFast when possible</strong> to create the <code>.eot</code> fonts, and failing that, <strong>will use ttf2eot as a fallback</strong>. EOTFast is the preferred solution because it can compress the converted file, but since it only runs under Windows, ttf2eot is needed for the other operating systems.  Note that I have experienced a problem running EOTFast under my copy of Windows 7.  I am not sure if this happens on all Windows 7 installations and I would love to hear comments in this area. I have sent a bug report to the developer, but in the meantime, you can use the Windows version of ttf2eot instead.</li>
<li><strong>I used Batik instead of Fontforge to generate the SVG fonts</strong> because I couldn&#8217;t get the Fontforge SVG fonts to work.  I don&#8217;t know why (to be honest, I didn&#8217;t look into it that much).</li>
<li><strong>I did not build a GUI for this tool.</strong> If anyone wants to, please feel free.  I would love to hear about it if you do.</li>
<li><strong>The first time you run the script under Cygwin, you may get this warning:</strong><br />
<blockquote class="code">
<pre>cygwin warning:
  MS-DOS style path detected: c:\Program Files\Batik\batik-1.7/batik-ttf2svg.jar
  Preferred POSIX equivalent is: /cygdrive/c/Program Files/Batik/batik-1.7/batik-ttf2svg.jar
  CYGWIN environment variable option "nodosfilewarning" turns off this warning.
  Consult the user's guide for more details about POSIX paths:

http://cygwin.com/cygwin-ug-net/using.html#using-pathnames
</pre>
</blockquote>
<p>This error won&#8217;t affect how the script runs &#8211; it is just complaining about the way Java is running Batik.  Since Java needs an MS-DOS path, ignore the warning.</li>
<li>Before using the tool, <strong>make sure you back up files that you don&#8217;t want over-written.</strong>  I am not responsible for any loss of files because you used the tool incorrectly (or because of a bug in the tool itself).</li>
<li><strong>Before you convert any fonts with this tool, please ensure that you have the legal right to do so</strong> by reading the license that comes with the font.</li>
</ol>
<h2>Image Credit</h2>
<p>The image at the top of this post was remixed using works from <a href="http://www.flickr.com/photos/mclabigail/2749884683/">Abigail Elder</a>, <a href="http://www.flickr.com/photos/24oranges/5146148857/sizes/l/in/photostream/">24oranges.nl</a>, <a href="http://www.flickr.com/photos/robbie1/3148808883/sizes/o/in/photostream/">Robbie Sproule</a> and <a href="http://www.flickr.com/photos/evilpeach/107445325/sizes/o/in/photostream/">Lisa Brank</a>.</p>
<p><a href="https://github.com/zoltan-dulac/css3FontConverter" class="exampleLink">Download the CSS3 Font Converter from GitHub</a></p>
]]></content:encoded>
			<wfw:commentRss>http://www.useragentman.com/blog/2011/02/20/converting-font-face-fonts-quickly-in-any-os/feed/</wfw:commentRss>
		<slash:comments>8</slash:comments>
		</item>
		<item>
		<title>Giving Challenged @font-face Fonts The Italics Makeover</title>
		<link>http://www.useragentman.com/blog/2010/09/07/giving-challenged-font-face-fonts-the-italics-makeover/</link>
		<comments>http://www.useragentman.com/blog/2010/09/07/giving-challenged-font-face-fonts-the-italics-makeover/#comments</comments>
		<pubDate>Wed, 08 Sep 2010 03:59:34 +0000</pubDate>
		<dc:creator>zoltan</dc:creator>
				<category><![CDATA[@font-face]]></category>
		<category><![CDATA[CSS]]></category>
		<category><![CDATA[CSS3]]></category>
		<category><![CDATA[Fonts]]></category>
		<category><![CDATA[transform]]></category>

		<guid isPermaLink="false">http://www.useragentman.com/blog/?p=1560</guid>
		<description><![CDATA[<img src="http://www.useragentman.com/blog/wp-content/uploads/2010/09/italics.png" /> Have a font that doesn't have an italics variant? Does your browser try to attempt to "obliquify" it (badly) or not do anything at all? There is a simple solution to this problem using CSS3 Transforms.]]></description>
			<content:encoded><![CDATA[<p>See the nice italicized text in the heading of this article?  It is not so obvious to style as you may think.  There are many great free and commercial fonts out there that allow @font-face embedding.  Unfortunately, not all of them have an italics variant for one reason or another.  For example, the font I use for my blogs headlines, <a href="http://www.fonts.info/info/press/free-fonts-for-font-face-embedding.htm">Graublau Sans Web</a>, does not have a true italics variant included with it, while the font I use for the blog&#8217;s copy, <a href="http://www.fontsquirrel.com/fonts/Droid-Sans">Droid Sans</a>, does.  When a font doesn&#8217;t have an italics variant, and you try to italicize it in a web-page using <code>&lt;i&gt;</code> and <code>&lt;em&gt;</code> tags, the results depend on the browser you are using:</p>
<ul>
<li>Safari, Chrome and Opera will render the font normally <strong>without</strong> italicizing it.</li>
<li>Internet Explorer and Firefox will attempt to italicize the font, but Internet Explorer will slant the font at a 20&deg; angle while Firefox implements a 10&deg; slant.</li>
</ul>
<table class="dataTable">
<thead>
<tr>
<th style="width: 33%">Internet Explorer 6.0</th>
<th style="width: 33%">Firefox 3.6</th>
<th style="width: 33%">Safari 4/Chrome 5/Opera 10</th>
</tr>
</thead>
<tbody>
<tr>
<td><a href="http://www.useragentman.com/blog/wp-content/uploads/2010/09/badItalics-IE.png"><img src="http://www.useragentman.com/blog/wp-content/uploads/2010/09/badItalics-IE.png" alt="Default Italics for Graublau Web in IE." width="106" height="38" class="alignnone size-full wp-image-1567" /></a></td>
<td><img src="http://www.useragentman.com/blog/wp-content/uploads/2010/09/badItalics-firefox.png" alt="Default Italics for Graublau Web in Firefox." width="106" height="38" class="alignnone size-full wp-image-1567" /></td>
<td><img src="http://www.useragentman.com/blog/wp-content/uploads/2010/09/badItalics-safari.png" alt="Default Italics for Graublau Web in Safari." width="106" height="38" class="alignnone size-full wp-image-1567" /></td>
</tr>
</table>
<p>This inconsistency is quite annoying from a user-experience point of view.  However, there is a way of leveling the playing field by using the CSS3 <code>transform</code> property.  And even though Internet Explorer doesn&#8217;t recognize <code>transform</code>, there is a workaround <strong>without using JavaScript</strong> using the <code>Matrix</code> Visual Filter.</p>
<h2>The CSS</h2>
<p>When I was a calligraphy student, I learned that the Italics script was to be written on a 10&deg; angle.  Using the CSS3 <code>transform</code> property, this can be achieved by using the <code>skewX()</code> function:</p>
<blockquote class="code">
<pre>
#content h1 em {
    font-family: "Graublau Web Bold", Arial, sans-serif;
    font-style: normal;

<span class="hilite">    -moz-transform:    skewX(-10deg);
    -o-transform:      skewX(-10deg);
    -webkit-transform: skewX(-10deg);
    transform:         skewX(-10deg);

    display: inline-block;
</span>
}
	</pre>
</blockquote>
<p>The <code>display: inline-block</code> is there since Safari, Chrome and Opera will not allow transformations on an <code>inline</code> element.</p>
<p>But what about Internet Explorer?  I <strong>could</strong> use my cssSandpaper script, but it is <strong>really</strong> simple to do without it:</p>
<blockquote class="code">
<pre>
#content h1 em {
    font-family: "Graublau Web Bold", Arial, sans-serif;
    font-style: normal;

    -moz-transform:    skewX(-10deg);
    -o-transform:      skewX(-10deg);
    -webkit-transform: skewX(-10deg);
    transform:         skewX(-10deg);

    display: inline-block;

<span class="hilite">    /* IE8+: must be on one line. */
    -ms-filter: "progid:DXImageTransform.Microsoft.Matrix(M11=1, M12=-0.1763269807084645, M21=0, M22=1, SizingMethod='auto expand')";

    /* IE6 and 7 */
    filter: progid:DXImageTransform.Microsoft.Matrix(
             M11=1,
             M12=-0.1763269807084645,
             M21=0,
             M22=1,
             SizingMethod='auto expand');</span>
}
	</pre>
</blockquote>
<p>This is the Microsoft <code>Matrix</code> Filter equivalent of <code>skewX(10deg)</code>. Let&#8217;s take a look at how this works in all the major browsers:</p>
<table class="dataTable">
<thead>
<tr>
<th style="width: 20%">Internet Explorer 6.0+</th>
<th style="width: 20%">Firefox 3.5+</th>
<th style="width: 20%">Safari 4+</th>
<th style="width: 20%">Chrome 5+</th>
<th style="width: 20%">Opera 10.5+</th>
</tr>
</thead>
<tbody>
<tr>
<td><img src="http://www.useragentman.com/blog/wp-content/uploads/2010/09/goodItalics-IE.png" alt="Italics Fix in IE" width="106" height="39" class="alignnone size-full wp-image-1574" /></td>
<td><img src="http://www.useragentman.com/blog/wp-content/uploads/2010/09/goodItalics-firefox.png" alt="Italics Fix in Firefox" width="106" height="39" class="alignnone size-full wp-image-1574" /></td>
<td><img src="http://www.useragentman.com/blog/wp-content/uploads/2010/09/goodItalics-safari.png" alt="Italics Fix in Safari" width="106" height="39" class="alignnone size-full wp-image-1574" /></td>
<td><img src="http://www.useragentman.com/blog/wp-content/uploads/2010/09/goodItalics-chrome.png" alt="Italics Fix in Chrome" width="106" height="39" class="alignnone size-full wp-image-1574" /></td>
<td><img src="http://www.useragentman.com/blog/wp-content/uploads/2010/09/goodItalics-opera.png" alt="Italics Fix in Opera" width="106" height="39" class="alignnone size-full wp-image-1574" /></td>
</tr>
</table>
<p>Isn&#8217;t that nice and consistent?  The screenshots are from the Windows versions of the browsers, but you can expect the same results for Mac and Linux versions as well.</p>
<h2>Is This <em>Really</em> Italics?</h2>
<p>Not really.  <strong>Technically, we are creating an oblique variant of this font.</strong> <a href="http://en.wikipedia.org/wiki/Oblique_type">The Wikipedia entry for Oblique fonts</a> states that many sans-serif fonts do not have italic variants, so this technique will be a useful one in a web developers toolkit.  </p>
<h2>Caveats</h2>
<ul>
<li>If you are going to make a few words in a row oblique, make sure you wrap the <code>&lt;i&gt;</code> and <code>&lt;em&gt;</code> tags around each word.  This is because the <code>display: inline-block</code> rule treats multiple words wrapped in one set of these tags as one word, which will cause problems when you want the words to wrap to the next line.<br />
<table>
<thead>
<tr>
<th>Wrapping multiple words with <strong>one</strong> <code>&lt;em&gt;</code> tag</th>
</tr>
</thead>
<tbody>
<tr>
<td><img src="http://www.useragentman.com/blog/wp-content/uploads/2010/09/badWordWrap.png" alt="Bad Word Wrap Example" title="badWordWrap" class="aligncenter size-full wp-image-1580" /></td>
</tr>
</tbody>
</table>
<table>
<thead>
<tr>
<th>Wrapping multiple words with separate <code>&lt;em&gt;</code> tags</th>
</tr>
</thead>
<tbody>
<tr>
<td>
<img src="http://www.useragentman.com/blog/wp-content/uploads/2010/09/goodWordWrap.png" alt="Good Word Wrap Example" title="goodWordWrap"  class="aligncenter size-full wp-image-1582" /></td>
</tr>
</tbody>
</table>
</li>
<li>If the oblique text does not have a solid background color, it will appear &#8220;blocky&#8221; or &#8220;pixely&#8221; in IE.  To fix this, you must use IE&#8217;s Chroma Visual Filter, as described in my last blog post, <a href="/blog/2010/09/02/how-to-make-cleartype-font-face-fonts-and-css-visual-filters-play-nicely-together/">How to Make ClearType, @font-face Fonts and CSS Visual Filters Play Nicely Together</a>.</li>
<li>In IE, multiple oblique words may appear to have more white space than the other browsers.  In this case you may need to create IE-only CSS rules that implement negative left margin on each word, using a solution like <a href="http://paulirish.com/2008/conditional-stylesheets-vs-css-hacks-answer-neither/">Paul Irish’s Conditional CSS Pattern</a>.</li>
<li>Webkit browsers apply the slanting correctly if a <code>font-style: normal</code> is declared in the @font-face rule for the font (thanks to <a href="http://levien.com/">Raph Levien</a> for commenting on this below.</li>
</ul>
]]></content:encoded>
			<wfw:commentRss>http://www.useragentman.com/blog/2010/09/07/giving-challenged-font-face-fonts-the-italics-makeover/feed/</wfw:commentRss>
		<slash:comments>5</slash:comments>
		</item>
		<item>
		<title>How to Make ClearType, @font-face Fonts and CSS Visual Filters Play Nicely Together</title>
		<link>http://www.useragentman.com/blog/2010/09/02/how-to-make-cleartype-font-face-fonts-and-css-visual-filters-play-nicely-together/</link>
		<comments>http://www.useragentman.com/blog/2010/09/02/how-to-make-cleartype-font-face-fonts-and-css-visual-filters-play-nicely-together/#comments</comments>
		<pubDate>Thu, 02 Sep 2010 20:49:51 +0000</pubDate>
		<dc:creator>zoltan</dc:creator>
				<category><![CDATA[@font-face]]></category>
		<category><![CDATA[ClearType]]></category>
		<category><![CDATA[CSS]]></category>
		<category><![CDATA[CSS3]]></category>
		<category><![CDATA[Fonts]]></category>
		<category><![CDATA[IE Visual Filters]]></category>
		<category><![CDATA[anti-aliased text]]></category>
		<category><![CDATA[blocky text]]></category>
		<category><![CDATA[cleartype]]></category>
		<category><![CDATA[CSS Filters]]></category>
		<category><![CDATA[IE]]></category>
		<category><![CDATA[ie filters]]></category>
		<category><![CDATA[Internet Explorers]]></category>
		<category><![CDATA[matrix]]></category>
		<category><![CDATA[opacity]]></category>
		<category><![CDATA[Visual Filters]]></category>

		<guid isPermaLink="false">http://www.useragentman.com/blog/?p=1526</guid>
		<description><![CDATA[<img src="http://www.useragentman.com/blog/wp-content/uploads/2010/09/ieBadAntiAliasFront.png" /> Ever had a problem with using IE's Alpha Visual Filter and getting blocky text? A solution has been found, and it doesn't use JavaScript.  I expect to hear a sigh of relief from many developers.]]></description>
			<content:encoded><![CDATA[<div class="importantNotes">
<h3>Update (Sept. 3, 2010)</h3>
<ul>
<li>This article originally has the <code>filter</code> and <code>-ms-filter</code> rules reversed, which is against <a href="http://blogs.msdn.com/b/ie/archive/2008/09/08/microsoft-css-vendor-extensions.aspx">Microsoft&#8217;s best practices</a> for IE8.  This error has been corrected.</li>
<li>Thanks to <a href="http://www.zomigi.com">Zoe Mickley Gillenwater</a> for pointing out that IE8 needs to have all the filter functions (i.e. all the stuff in the double quotes) on one line.</li>
</ul>
</div>
<p>The modern web developer wants to be able to use a variety of CSS3 effects together, but sometimes doing this in IE can be challenging, especially if you don&#8217;t want to use JavaScript.  Let&#8217;s take a look a common problem with IE: blocky text in IE when using IE Visual filters on a block of text.  For example, if you&#8217;ve ever tried to do <a href="http://davidwalsh.name/css-opacity">the cross-browser CSS opacity trick</a> to implement opacity in IE6, this problem manifests itself when the <strong>text is styled with no background color</strong>.  A developer uses this well-known cross browser CSS-foo to make this work:</p>
<blockquote class="code">
<pre>
#badAntiAliasing {
	opacity: 0.5;

        /* IE 8 */
        -ms-filter: "progid:DXImageTransform.Microsoft.Alpha(opacity=50)";

        /* IE 6,7 */
	filter: progid:DXImageTransform.Microsoft.Alpha(opacity=50);

}
</pre>
</blockquote>
<p>And it looks great in every browser, but <strong>it looks like crap in Internet Explorer 6 with ClearType turned on.</strong>  It is especially pronounced when using @font-face embedding with fonts that assume that some sort of anti-aliasing technology is being used.  The example below uses <a href="http://www.fonts.info/info/press/free-fonts-for-font-face-embedding.htm">Graublau Sans Web</a> with the Alpha filter to illustrate the issue:</p>
<table class="dataTable" style="margin-top: 1em">
<thead>
<tr>
<th>Opacity Solution in IE</th>
<th>Opacity Solution in every other browser</th>
</tr>
</thead>
<tbody>
<tr>
<td><a href="http://www.useragentman.com/blog/wp-content/uploads/2010/09/ieBadAntiAlias.png"><img src="http://www.useragentman.com/blog/wp-content/uploads/2010/09/ieBadAntiAlias.png" alt="" title="ieBadAntiAlias" width="361" height="58" class="alignnone size-full wp-image-1530" /></a></td>
<td><a href="http://www.useragentman.com/blog/wp-content/uploads/2010/09/firefoxAntiAlias.png"><img src="http://www.useragentman.com/blog/wp-content/uploads/2010/09/firefoxAntiAlias.png" alt="" title="firefoxAntiAlias" width="360" height="50" class="alignnone size-full wp-image-1529" /></a></td>
</tr>
</tbody>
</table>
<p>This has been a known problem with IE ever since 2006 when ClearType&#8217;s product manager, Peter Gurevich, <a href="http://blogs.msdn.com/b/ie/archive/2006/08/31/730887.aspx">announced on the IEBlog their decision to disable ClearType on elements that use any Visual Filter</a>.  If you read the comments on this blog article, you will see many upset developers.  I was one of them, since this not only affects the <a href="http://msdn.microsoft.com/en-us/library/ms532967%28v=VS.85%29.aspx">Alpha Filter</a>, but all of <a href="http://msdn.microsoft.com/en-us/library/ms532849%28v=VS.85%29.aspx">IE&#8217;s Visual Filters</a>, some of which I use in cssSandpaper to get IE to support CSS3 properties like <code>transform</code>.</p>
<p>Today, however, we can rejoice.  There is a <strong>usable workaround that will make ClearType rendered fonts look nice when using Visual Filters</strong>.  In our example above, here is what needs to be done:</p>
<blockquote class="code">
<pre>
body.ie6 #goodAntiAliasing,
body.ie7 #goodAntiAliasing,
body.ie8 #goodAntiAliasing {
	background-color: <span class="hilite">white</span>;
}

#goodAntiAliasing {
	opacity: 0.5;

        /* IE 8: yes, it is ugly but it has to be on one line. :-( */
        -ms-filter: "progid:DXImageTransform.Microsoft.Chroma(<span class="hilite">color='white'</span>) progid:DXImageTransform.Microsoft.Alpha(opacity=50)";

        /* IE 6,7 is more flexible: it can be on multiple lines. */
	filter: progid:DXImageTransform.Microsoft.Chroma(<span class="hilite">color='white'</span>)
                progid:DXImageTransform.Microsoft.Alpha(opacity=50);

}
</pre>
</blockquote>
<p>What is going on here?</p>
<ol>
<li>The first rule sets the background color of the container to a color that is represents the color of the majority of the background image on the page.  <strong>Note that this rule uses <a href="http://paulirish.com/2008/conditional-stylesheets-vs-css-hacks-answer-neither/">Paul Irish&#8217;s Conditional CSS Pattern</a> to serve it only to IE.</strong></li>
<li>The second rule executes two of IE&#8217;s Visual Filters:
<ul>
<li>the Chroma Visual Filter, which tells IE &#8220;Please make this color transparent&#8221;.  The color we choose to make transparent is the one we selected in the first rule.</li>
<li>the Alpha Visual Filter, which does the opacity trick</li>
</ul>
</ol>
<table class="dataTable">
<thead>
<tr>
<th>Default Opacity in IE</th>
<th>New Opacity Solution in IE</th>
</tr>
</thead>
<tbody>
<tr>
<td><a href="http://www.useragentman.com/blog/wp-content/uploads/2010/09/ieBadAntiAlias.png"><img src="http://www.useragentman.com/blog/wp-content/uploads/2010/09/ieBadAntiAlias.png" alt="" title="ieBadAntiAlias" width="361" height="58" class="alignnone size-full wp-image-1530" /></a></td>
<td><a href="http://www.useragentman.com/blog/wp-content/uploads/2010/09/ieBadAntiAlias.png"><img src="http://www.useragentman.com/blog/wp-content/uploads/2010/09/ieGoodAntiAlias.png" alt="" title="ieBadAntiAlias" width="361" height="58" class="alignnone size-full wp-image-1530" /></a></td>
</tr>
</tbody>
</table>
<p><strong>These filters must be in the order given</strong>, and not the other way around.  Note also that care must be given that <strong>the color chosen to be transparent should be the average color of what is behind the text being styled</strong>, otherwise you will get less than optimal results.  If this background is a complex image, just use the colour that&#8217;s used most often.</p>
<p>This fixes not only the IE opacity problem, but also issues with other Visual Filters, such as <code>Matrix</code>.  I will be updating cssSandpaper to use this trick so that transformed objects in IE won&#8217;t look so blocky.</p>
<p><a class="exampleLink" href="/tests/fontFacePlusFilter/">Take a look at the solution in action (make sure you look at it in IE in order to get the full effect)</a></p>
]]></content:encoded>
			<wfw:commentRss>http://www.useragentman.com/blog/2010/09/02/how-to-make-cleartype-font-face-fonts-and-css-visual-filters-play-nicely-together/feed/</wfw:commentRss>
		<slash:comments>14</slash:comments>
		</item>
		<item>
		<title>Introducing: The Type Rendering Project</title>
		<link>http://www.useragentman.com/blog/2009/11/30/introducing-the-type-rendering-project/</link>
		<comments>http://www.useragentman.com/blog/2009/11/30/introducing-the-type-rendering-project/#comments</comments>
		<pubDate>Mon, 30 Nov 2009 17:05:58 +0000</pubDate>
		<dc:creator>zoltan</dc:creator>
				<category><![CDATA[@font-face]]></category>
		<category><![CDATA[CSS]]></category>
		<category><![CDATA[CSS3]]></category>
		<category><![CDATA[Fonts]]></category>

		<guid isPermaLink="false">http://www.useragentman.com/blog/?p=412</guid>
		<description><![CDATA[Join a project that will allow developers to <strong>find ways to make web type look better <em>right now</em></strong>.]]></description>
			<content:encoded><![CDATA[<p><div id="attachment_416" class="wp-caption alignleft" style="width: 260px"><img class="size-medium wp-image-416 " title="Type Rendering Project Logo" src="http://www.useragentman.com/blog/wp-content/uploads/2009/11/r-300x300.png" alt="Type Rendering Project Logo" width="250" height="250" /><p class="wp-caption-text"><span></span></p></div></p>
<p>Although this blog wasn&#8217;t meant to be a forum on <em>just</em> CSS font-embedding, it is a topic of great interest to me and has been the inspiration of a few articles here (my article on <a href="/blog/2009/11/29/how-to-detect-font-smoothing-using-javascript/">JavaScript font-smoothing detection</a> being the latest).  As a result, I have been very fortunate in meeting a lot of interesting and like-minded individuals who want to make the web a better place for typography.</p>
<p>One of the more vocal ones, <a href="http://paulirish.com/">Paul Irish</a>, asked me to join a project that will allow developers to <strong>find ways to make web type look better <em>right now</em></strong>.  Other members include web font blogger Tim Brown of <a href="http://www.nicewebtype.com/">Nice Web Type</a> and Ethan Dunham of the excellent font resource <a href="http://fontsquirrel.com/">Font Squirrel</a>.  The result is <a href="http://typerendering.com/">The Type Rendering Project</a> &#8211; we’ve set some goals and would like to open up dialogue with you to fulfill them. We&#8217;re asking for your participation, and lots of expert advice, to fulfill these intentions. If you are interested and are a Twitter user, <a href="http://twitter.com/typerendering">follow us</a> &#8211;  and more importantly, <a href="http://twitter.com/home?status=I+care+about+how+type+looks+on+the+web,+so+I+follow+%40typerendering.">tell folks you care about how type looks on websites</a>.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.useragentman.com/blog/2009/11/30/introducing-the-type-rendering-project/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>How to Detect Font-Smoothing Using JavaScript</title>
		<link>http://www.useragentman.com/blog/2009/11/29/how-to-detect-font-smoothing-using-javascript/</link>
		<comments>http://www.useragentman.com/blog/2009/11/29/how-to-detect-font-smoothing-using-javascript/#comments</comments>
		<pubDate>Sun, 29 Nov 2009 19:41:50 +0000</pubDate>
		<dc:creator>zoltan</dc:creator>
				<category><![CDATA[@font-face]]></category>
		<category><![CDATA[ClearType]]></category>
		<category><![CDATA[CSS]]></category>
		<category><![CDATA[CSS3]]></category>
		<category><![CDATA[Fonts]]></category>
		<category><![CDATA[JavaScript]]></category>

		<guid isPermaLink="false">http://www.useragentman.com/blog/?p=338</guid>
		<description><![CDATA[Not all @font-face fonts look good when font-smoothing is turned off.  Now you can detect whether a font smoothing technology is being used and serve alternative fonts for those users.]]></description>
			<content:encoded><![CDATA[<div class="importantNotes">
<h3>Interested in making web typography look better?</h3>
<p><a href="/blog/2009/11/30/introducing-the-type-rendering-project/">Read about The Type Rendering Project!</a></p>
</div>
<p><div id="attachment_404" class="wp-caption alignleft" style="width: 260px"><img class="size-full wp-image-404 " title="fontSmoothingLeader" src="http://www.useragentman.com/blog/wp-content/uploads/2009/11/fontSmoothingLeader.png" alt="Image a remix of Wikimedia Images http://bit.ly/5LufSS and http://bit.ly/6Jjlbd" width="250" height="250" /><p class="wp-caption-text">
<div>Examples of font-smoothing and subpixel-rendering as performed by technologies like ClearType.  Image Credit: Wikimedia Commons users <a href='http://commons.wikimedia.org/wiki/File:Antialias-vrs-Cromapixel.png'>Pandries</a> and <a href='http://commons.wikimedia.org/wiki/File:ClearType02.png'>Kalan</a></div>
<p></p></div></p>
<p>In <a title="&quot;More @font-face in Depth&quot; article" href="http://www.useragentman.com/blog/2009/10/09/more-font-face-fun/">an earlier article</a>, I mentioned that <a title=" Boing Boing’s Redesign Uncovers the Dark Side of Web Fonts" href="http://www.webmonkey.com/blog/Boing_Boing_s_Redesign_Uncovers_the_Dark_Side_of_Web_Fonts">Boing-Boing had a few issues when they wanted to use @font-face embedding inside their website</a>.  In short, the problem was that some fonts look bad on computer monitors without font-smoothing enabled in the operating system.  This brought on a lot of discussion as to whether there was a way to detect whether or not font-smoothing was being used using JavaScript.  I initially thought there wasn&#8217;t a way, but after seeing a promising but incomplete method of detecting font-smoothing, I spent a few days devising a way to do it.</p>
<h2>Internet Explorer Does Something Easily (For a Change)</h2>
<p><a href="http://paulirish.com/">Paul Irish</a> mentioned to me and a few other colleagues that he came across <a href="http://silkworth.net/browser_os/cleartype.html">a page using an Active X control that detects font-smoothing in IE</a>.  I was so hopeful &#8230; until I realized that this only works on browsers that have come into contact with <a href="http://www.microsoft.com/typography/cleartype/tuner/tune.aspx">Microsoft&#8217;s online Cleartype Tuner</a>, which I visited with my copy of IE months before.  If a users had never visited this page, the script would fail.</p>
<p>I was more disappointed because Googling &#8220;javascript cleartype&#8221; did not point to anything useful.  However, searching for &#8220;javascript font-smoothing&#8221; pointed me to an article that told me about Internet Explorer&#8217;s <a href="http://www.java2s.com/Code/JavaScript/Window-Browser/ScreenfontSmoothingEnabled.htm">screen.fontSmoothingEnabled</a> property.  This gives us what we need &#8230; but only in Internet Explorer.  How on Earth can we detect font-smoothing in other browsers, and in non-Windows operating systems?</p>
<h2>Canvas to the Rescue</h2>
<p><div id="attachment_390" class="wp-caption aligncenter" style="width: 420px"><img class="size-full wp-image-390" title="aliasAndAntiAliasComparison" src="http://www.useragentman.com/blog/wp-content/uploads/2009/11/aliasAndAntiAliasComparison.png" alt="aliasAndAntiAliasComparison" width="410" height="244" /><p class="wp-caption-text">Letter &#39;O&#39; , Arial font, 32 px, rendered both without (left) and with (right) font-smoothing</p></div></p>
<p style="text-align: center;">
<p>I then thought about about the screenshots I made for <a href="/blog/2009/09/20/font-face-in-depth/">the @font-face in Depth article</a>.  Can a browser render a black glyph and detect if there is some sort of non-black pixel colouring around the its edges of the glyphs? <strong> A human can tell the difference</strong>:  if there are some non-black pixels around the edge of the glyph, it must be using font-smoothing.</p>
<p>But <strong>web browsers can do this too!</strong> Just have the browser draw a letter in black inside a <code>canvas</code> tag, and then have it sift through the canvas&#8217; pixels to see if there are any that are <strong>not</strong> pure black or pure white (more accurately, have the browser check the alpha channel to see if there are any semi-transparent pixels, which have a value that is not 0 or 255).    If there are no semi-transparent pixels, then the algorithm assumes that no font-smoothing is being used. I wrote an JavaScript routine that does this &#8211; it starts from co-ordinate (8,1) and scans left to right, to the bottom of the canvas (any point on near the top on the left-hand side of the canvas would have done as well).</p>
<p>The result is a JavaScript object, <code>TypeHelpers</code>, which implements this routine in one method, <code>hasSmoothing()</code>:</p>
<blockquote class="code">
<pre>var TypeHelpers = new function(){

   // I use me instead of this.  For reasons why, please read:
   // http://w3future.com/html/stories/callbacks.xml
   var me = this;

   me.hasSmoothing = function(){

      // IE has screen.fontSmoothingEnabled - sweet!
      if (typeof(screen.fontSmoothingEnabled) != "undefined") {
         return screen.fontSmoothingEnabled;
      } else {

         try {

            // Create a 35x35 Canvas block.
            var canvasNode = document.createElement('canvas');
            canvasNode.width = "35";
            canvasNode.height = "35"

            // We must put this node into the body, otherwise
            // Safari Windows does not report correctly.
            canvasNode.style.display = 'none';
            document.body.appendChild(canvasNode);
            var ctx = canvasNode.getContext('2d');

            // draw a black letter 'O', 32px Arial.
            ctx.textBaseline = "top";
            ctx.font = "32px Arial";
            ctx.fillStyle = "black";
            ctx.strokeStyle = "black";

            ctx.fillText("O", 0, 0);

            // start at (8,1) and search the canvas from left to right,
            // top to bottom to see if we can find a non-black pixel.  If
            // so we return true.
            for (var j = 8; j &lt;= 32; j++) {
               for (var i = 1; i &lt;= 32; i++) {

                  var imageData = ctx.getImageData(i, j, 1, 1).data;
                  var alpha = imageData[3];

                  if (alpha != 255 &amp;&amp; alpha != 0) {
                     return true; // font-smoothing must be on.
                  }
               }

            }

            // didn't find any non-black pixels - return false.
            return false;
         }
         catch (ex) {
            // Something went wrong (for example, Opera cannot use the
            // canvas fillText() method.  Return null (unknown).
            return null;
         }
      }
   }

   me.insertClasses = function(){
      var result = me.hasSmoothing();
      var htmlNode = document.getElementsByTagName('html')[0];
      if (result == true) {
         htmlNode.className += " hasFontSmoothing-true";
      } else if (result == false) {
            htmlNode.className += " hasFontSmoothing-false";
      } else { // result == null
            htmlNode.className += " hasFontSmoothing-unknown";
      }
   }

}

// if EventHelpers.js is included, insert the hasFontSmoothing CSS classes
if (window.EventHelpers) {
   EventHelpers.addPageLoadEvent('TypeHelpers.insertClasses')
}</pre>
</blockquote>
<p>Note the object also has an <code>insertClasses()</code> method.  This method, when run, adds a class to the <code>html</code> tag:</p>
<ul>
<li><code>hasFontSmoothing-true</code> if font-smoothing is being used</li>
<li><code>hasFontSmoothing-false</code> if it is not</li>
<li><code>hasFontSmoothing-unknown</code> if the user agent is unable to tell</li>
</ul>
<p>This makes it easy for developers who don&#8217;t want to mess with JavaScript code and just want  to use CSS.</p>
<p>Also note the <code>EventHelpers.addPageLoadEvent()</code> call at the end of the code.  This method (which is part of <code>EventHelpers.js</code>, included with the archive below) <a href="http://dean.edwards.name/weblog/2005/09/busted/">implements Dean Edwards&#8217; window.onload alternative which doesn&#8217;t wait for all the objects in the page to be loaded</a>.   I use this implementation to execute <code>TypeHelpers.insertClasses()</code> when the page loads so any font-detection CSS rules will work right away.  Please feel free to change this code to use the equivalent function call in Dojo, Prototype, jQuery, or whatever JavaScript code framework you prefer.</p>
<h2>Example #1: JavaScript Font Smoothing Detection</h2>
<p>Enough of theory &#8230; let&#8217;s look at it in practice!  To show how to detect font-smoothing with JavaScript, I created a page that, when the page is loaded, checks to see if it can tell if font-smoothing has been implemented and tells the user.  Here is the code that does this check:</p>
<blockquote class="code">
<pre>function displayInfo() {

   var message;
   var isFontSmoothingOn = TypeHelpers.hasSmoothing();
   if (isFontSmoothingOn == true) {
      message = "This browser is using a font-smoothing technology";
   } else if (isFontSmoothingOn == false) {
      message = "This browser isn't using a font-smoothing technology"
   } else {
      message = "We could not detect if font-smoothing is being used."
   }
   document.getElementById('detectInfo').innerHTML = message;

}

window.onload = displayInfo;</pre>
</blockquote>
<p><a class="exampleLink" href="/tests/fontSmoothing/">See the above code in action</a></p>
<h2>Example #2: CSS Font Smoothing Detection</h2>
<p>As implied earlier, this library can help CSS use different fonts if the browser is using a font-smoothing technology.   For example, using the following CSS will allow a browser to use the Droid Sans embedded font only if it using font-smoothing — otherwise, it will use Arial:</p>
<blockquote class="code">
<pre>@font-face {
	font-family: "Droid Sans";
	src: url("/shared/fonts/DroidSans/DroidSans.eot");
	src: local("Droid Sans"),
	     local("Droid Sans"),
	     url("/shared/fonts/DroidSans/DroidSans.ttf") format("truetype");
}

body {
	font-family: "Arial", "Helvetica", sans-serif;
}

html.hasFontSmoothing-true body {
	font-family: "Droid Sans", "Arial", "Helvetica", sans-serif;
}</pre>
</blockquote>
<p>We can also serve special content to users depending on the way fonts are rendered on their browser.  We first create content for all three scenerios (browser uses font-smoothing, browser doesn&#8217;t use font-smoothing, and the &#8220;we cannot detect&#8221; case) and wrap the content inside &lt;code&gt;div&lt;/code&gt; tags using appropriate CSS classes:</p>
<blockquote class="code">
<pre>&lt;div class="fontSmoothingMessage initiallyHidden"&gt;
    &lt;p&gt;You browser &lt;strong&gt;is&lt;/strong&gt; rendering this page
    with font-smoothing. Because of that, we will attempt
    to serve up the Droid Sans font to render this page,
    because we think it looks cool. If you are using a
    browser (such as Google Chrome) that cannot render
    downloaded True Type fonts by default, then the page
    will be rendered using Arial instead.&lt;/p&gt;
&lt;/div&gt;

&lt;div class="noFontSmoothingMessage initiallyHidden"&gt;
    Your browser &lt;strong&gt;is not&lt;/strong&gt; rendering this
    page with font-smoothing. It is for that reason we have
    decided to use the plain old Arial font to render this
    page, because it is hinted for use for displays that
    don't employ a font-smoothing technology.
&lt;/div&gt;

&lt;div class="unknownFontSmoothingMessage initiallyHidden"&gt;
    &lt;strong&gt;We are not sure&lt;/strong&gt; if your browser is
    rendering this page with a font-smoothing technology.
    It is for that reason we have decided to use the plain
    old Arial font to render this page, because it is
    hinted for use for displays that don't employ a
    font-smoothing technology.
&lt;/div&gt;</pre>
</blockquote>
<p>Note all the <code>div</code> tags are members of the class <code>initiallyHidden</code>.  This class will be used to hide all font-smoothing related content until the script kicks in.</p>
<p>However, all this will not work unless we use the following CSS code:</p>
<blockquote class="code">
<pre>.initiallyHidden {
	display: none;
}

html.hasFontSmoothing-true .fontSmoothingMessage,
html.hasFontSmoothing-false .noFontSmoothingMessage,
html.hasFontSmoothing-unknown .unknownFontSmoothingMessage {
	display: block;
}</pre>
</blockquote>
<p>Of course, this whole soltution relies on whether JavaScript being turned on in the user&#8217;s browser.  This should be kept in mind when implementing this solution.</p>
<p><a class="exampleLink" href="/tests/fontSmoothing/cssExample.html">See the above code in action</a></p>
<h2>Download</h2>
<p>All code used in this article can be downloaded below (<strong>Note:</strong> version 1.0 was missing the Droid Sans Fonts which have now been put into the archive.  Thanks to John Faulds for pointing this out).</p>
<p><a class="exampleLink" href="/downloads/TypeHelpers.zip">TypeHelpers.js v.1.0a and sample code.</a></p>
<p>With the help of <a href="http://www.nicewebtype.com">Tim Brown</a>, it was determined that the code detected font-smoothing correctly in the following browsers:</p>
<ul>
<li>Internet Explorer 6 and up on Windows XP and higher.</li>
<li>Firefox 3.5 and higher on Windows XP and higher, Mac OS X 10.4 and higher, and Ubuntu Linux 9.10 (and probably lower)</li>
<li>Chrome 3.0 on Windows XP and higher</li>
<li>Safari 4.0.3 on Windows XP and higher and Mac OS X 10.4 and higher</li>
</ul>
<p>This script <strong>cannot detect font-smoothing in any version of Opera</strong> (at the time of this writing, this includes all versions up to 10.10), since it cannot write text inside the canvas element in a way we can poll the pixels afterwards.  If anyone can find a way of making it work with Opera, please write a comment below — I&#8217;d love to be able to support this browser.</p>
<h2>Testing Caveats</h2>
<p>Testing font-smoothing in most Windows web browsers is easy since it can be turned off inside the Display control panel. However, when using Safari for Windows, it is necessary to navigate inside Safari&#8217;s <strong>Appearance</strong> preferences and set the <strong>Font-smoothing</strong> option to <strong>Windows Standard</strong>.  This is because  by default, Safari uses it&#8217;s own built-in font-rendering engine which doesn&#8217;t seem to render aliased fonts.  In Mac OS X, it seems anti-aliasing only works for fonts below a certain size, so aliased fonts don&#8217;t seem to be an issue with that operating system.  In Ubuntu Linux I have yet to find a way of shutting of font-smoothing.  If anyone knows a way, please let me know.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.useragentman.com/blog/2009/11/29/how-to-detect-font-smoothing-using-javascript/feed/</wfw:commentRss>
		<slash:comments>58</slash:comments>
		</item>
		<item>
		<title>More @font-face fun</title>
		<link>http://www.useragentman.com/blog/2009/10/09/more-font-face-fun/</link>
		<comments>http://www.useragentman.com/blog/2009/10/09/more-font-face-fun/#comments</comments>
		<pubDate>Sat, 10 Oct 2009 00:53:36 +0000</pubDate>
		<dc:creator>zoltan</dc:creator>
				<category><![CDATA[@font-face]]></category>
		<category><![CDATA[CSS]]></category>
		<category><![CDATA[Fonts]]></category>
		<category><![CDATA[SVG]]></category>
		<category><![CDATA[@font-face. opera. chrome]]></category>
		<category><![CDATA[anti-aliasing]]></category>
		<category><![CDATA[cleartype]]></category>
		<category><![CDATA[svg fonts]]></category>

		<guid isPermaLink="false">http://www.useragentman.com/blog/?p=237</guid>
		<description><![CDATA[My first post @font-face in Depth got a huge amount of unexpected attention.  Thank you all for your comments and criticism.  Since the post, there have been quite a bit of information I have read about and thought I should share. SVG fonts for Opera and Chrome Jonathan Snook wrote a great article regarding Opera [...]]]></description>
			<content:encoded><![CDATA[<p>My first post <a href="/blog/2009/09/20/font-face-in-depth/">@font-face in Depth</a> got a <strong>huge</strong> amount of unexpected attention.  Thank you all for your comments and criticism.  Since the post, there have been quite a bit of information I have read about and thought I should share.</p>
<h2>SVG fonts for Opera and Chrome</h2>
<p><a href="http://www.snook.ca/">Jonathan Snook</a> wrote a great article <a href="http://www.snook.ca/archives/html_and_css/becoming-a-font-embedding-master">regarding Opera 10 and Google Chrome supporting SVG fonts</a> (Chrome can load them without any pesky command line switch!).   He mentions how to convert TrueType fonts to this format using <a href="http://xml.apache.org/batik/">Batik</a>, and that by removing all the <code>&lt;hkren&gt;</code> elements inside the file&#8217;s XML can make the font smaller than the original TrueType file.  Too bad the browsers don&#8217;t support this format.</p>
<h2>Opera&#8217;s buggy implementation</h2>
<p>I noticed after I launched my first @font-face article that Opera was not loading the fonts on my blog when users visited more than one page.  It turns out that Opera 10&#8242;s implementation of @font-face is a little buggy.  When you feed it a page with an embedded font, you may not see the embedded fonts properly, like in the screenshot below:</p>
<p><div id="attachment_238" class="wp-caption aligncenter" style="width: 310px"><a href="http://www.useragentman.com/blog/wp-content/uploads/2009/10/screenshotOpera.png"><img class="size-medium wp-image-238 " title="screenshotOpera" src="http://www.useragentman.com/blog/wp-content/uploads/2009/10/screenshotOpera-300x215.png" alt="screenshotOpera" width="300" height="215" /></a><p class="wp-caption-text">Opera sometimes doesn&#39;t load the font at all, and removes other styling (click to enlarge).</p></div></p>
<p><a href="http://readableweb.com/opera-admits-font-face-bugs-in-opera-10/">According to Opera</a>, this happens when &#8220;specifying different weights and styles for a single font-family name&#8221;.  Håkon Wium Lie, the company&#8217;s Chief Technology Officer , <a href="http://devfiles.myopera.com/articles/751/webfonts-workaround.html">has described a work-around</a> until the company can fix the problem properly.</p>
<p>I am debating whether to implement the work around on my site, or to wait for Opera to fix the problem and patch all Opera 10 installations via auto-update (I&#8217;m leaning towards the latter).</p>
<h2>Performance Issues With Font Embedding</h2>
<p>One of the comments on the last article came from <a href="http://stevesouders.com/">Steve Souders</a> who had <a href="/blog/2009/09/20/font-face-in-depth/#comment-37">performance concerns with font-embedding</a>.  Paul Irish came back with information showing the <a href="http://paulirish.com/2009/fighting-the-font-face-fout/">when browsers load the fonts, and what they do before the font is loaded</a>.  He also shows how to use JavaScript to make the loading behaviour consistent between browsers.</p>
<p>The performance issues with font-embedding is something I am going to be keeping an eye on, especially when it comes to font-services, which the OpenType site believes will be <a href="http://opentype.info/blog/2009/07/29/why-webfont-services-are-the-future-of-fonts-on-the-web/">the future of web font distribution for commercial fonts</a>.  Although it doesn&#8217;t seem like much of an issue currently (my blog <em>seems</em> to load quickly), I don&#8217;t want to do anything that would slow down my web applications &#8211; especially if I am using them just to make the text look a little prettier.</p>
<h2>Windows XP Rendering Issues</h2>
<p>Boing-Boing had a bad experience with font-embedding.  Turns out <a href="http://www.webmonkey.com/blog/Boing_Boing_s_Redesign_Uncovers_the_Dark_Side_of_Web_Fonts">they got a lot of complaints when they decided to incorporate it into their website</a>.  The reason: some users didn&#8217;t have ClearType turned on, and the font Boing-Boing chose looked &#8220;like ass&#8221; without ClearType.</p>
<p>Below are screenshots of this site without ClearType on:</p>
<p><div id="attachment_250" class="wp-caption aligncenter" style="width: 449px"><img class="size-full wp-image-250" title="ieNoAA" src="http://www.useragentman.com/blog/wp-content/uploads/2009/10/ieNoAA.png" alt="ieNoAA" width="439" height="336" /><p class="wp-caption-text">Internet Explorer without ClearType</p></div></p>
<p style="text-align: center;">
<p><div id="attachment_251" class="wp-caption aligncenter" style="width: 465px"><img class="size-full wp-image-251" title="firefoxNoAA" src="http://www.useragentman.com/blog/wp-content/uploads/2009/10/firefoxNoAA.png" alt="Firefox without ClearType" width="455" height="327" /><p class="wp-caption-text">Firefox without ClearType</p></div></p>
<p>The article stated that there are quite a few XP computers which apparently don&#8217;t have ClearType on by default. I wonder if there are any stats to back that up. If so, then developers embed fonts into pages should test that scenario as well.  It does look different.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.useragentman.com/blog/2009/10/09/more-font-face-fun/feed/</wfw:commentRss>
		<slash:comments>10</slash:comments>
		</item>
		<item>
		<title>@font-face in Depth</title>
		<link>http://www.useragentman.com/blog/2009/09/20/font-face-in-depth/</link>
		<comments>http://www.useragentman.com/blog/2009/09/20/font-face-in-depth/#comments</comments>
		<pubDate>Sun, 20 Sep 2009 04:04:13 +0000</pubDate>
		<dc:creator>admin</dc:creator>
				<category><![CDATA[@font-face]]></category>
		<category><![CDATA[ClearType]]></category>
		<category><![CDATA[converting]]></category>
		<category><![CDATA[CSS]]></category>
		<category><![CDATA[FontForge]]></category>
		<category><![CDATA[Fonts]]></category>
		<category><![CDATA[embedded font]]></category>
		<category><![CDATA[eot]]></category>
		<category><![CDATA[font]]></category>
		<category><![CDATA[font-embedding]]></category>
		<category><![CDATA[fontforge]]></category>
		<category><![CDATA[otf]]></category>
		<category><![CDATA[ttf]]></category>
		<category><![CDATA[ttf2eot]]></category>

		<guid isPermaLink="false">http://www.useragentman.com/blog/?p=13</guid>
		<description><![CDATA[The fact that we can now choose any font to embed inside our web pages and applications using @font-face is something to celebrate, and removes a long existing set of handcuffs placed on web designers.  This article covers how to use @font-face in all browsers, as well as some interesting little-known technical details.]]></description>
			<content:encoded><![CDATA[<div class="importantNotes">
<h3>Updates</h3>
<ul>
<li><strong>(Oct 13, 2009):</strong> I have written a <a href="/blog/2009/10/09/more-font-face-fun/">follow up article</a> which explores SVG fonts,<br />
	Opera 10 issues, and more</li>
<li><strong>(Oct 28, 2010):</strong> This article has been translated into <a href="http://www.movavi.com/opensource/font-face-in-depth-be">Belorussian</a> by <a href="http://www.movavi.com/">movavi</a>.</li>
</ul>
</div>
<p><div id="attachment_28" class="wp-caption alignleft" style="width: 250px"><a title="image Flickr page" href="http://www.flickr.com/photos/martab/1757415036/" target="_blank"><img class="size-full wp-image-28      " title="image Flickr page" src="http://www.useragentman.com/blog/wp-content/uploads/2009/09/fontintro2.jpg" alt="" width="240" height="180" /></a><p class="wp-caption-text">Photo by marta.b (Source: Flickr)</p></div></p>
<p>When I told one of my co-workers how excited I was that almost all the major browser vendors now supported font-embedding in their products, I got the same reaction from her that Bert from Sesame Street got when he told Ernie how <a title="Link to classic Sesame Street clip &quot;Bert's Bottlecaps&quot; via YouTube" href="http://www.youtube.com/watch?v=2Ls2vNfQxyc">exciting he thought bottle cap collecting was</a> (yes, gratuitous ridicule was involved).  Now, while I can somewhat understand her disinterest (she is not a front-end web developer, but a Java programmer), I defend my enthusiasm by stating here that fonts are a really important part of web design, and the fact that we can now theoretically choose <strong>any</strong> font to embed inside our web pages and applications is something to celebrate.</p>
<p>Sure, workarounds such as <a title="Mike Davidson article &quot;sIFR 2.0: Rich Accessible Typography for the Masses&quot;" href="http://www.mikeindustries.com/blog/sifr/">sIFR</a> and <a title="Cufón homepage" href="http://cufon.shoqolate.com/generate/">Cufón</a> have existed for quite a while now, but they have drawbacks (they both are best used only for headings, and Cufón  doesn&#8217;t do well at allowing copying and pasting its content).  If you really want to embed fonts in your webpages, I believe that @font-face is the safest, future-proof option.</p>
<h2>Why care about fonts?</h2>
<p>My Java developer colleague may not understand why fonts are important, but she is a regular reader of  <a href="http://www.newyorker.com/">The New Yorker</a>.  Even though its website doesn&#8217;t use @font-face embedding (the standard New Yorker font is embedded in site using images), the developers of the site obviously know why fonts are important:</p>
<ul>
<li><strong>Fonts identify who the content belongs to.</strong> Just take a look at the content and without looking at the URL bar, you know exactly where you are &#8211; that font is highly integrated into that organization&#8217;s identity and branding.  Replace the New Yorker font with Arial and it&#8217;ll look like any old website.</li>
<li><strong>Fonts given an emotional association to the content. </strong>The content has an air of authority because of the font it uses (after all, it looks like it was written by The New Yorker).  It is the reason why phishing sites use the fonts, colours and logos of the banks they are posing as.</li>
<li><strong>Fonts can help (or hinder) the legability of content.</strong> Scanning the content, you can tell where the article titles are, where the navigation is, and what section each of the articles belong to.  This is all because of the way fonts are used on the site.</li>
</ul>
<p><div id="attachment_60" class="wp-caption aligncenter" style="width: 460px"><img class="size-full wp-image-60  " title="newYorkerScreenshot" src="http://www.useragentman.com/blog/wp-content/uploads/2009/09/newYorkerScreenshot1.jpg" alt="newYorkerScreenshot" width="450" height="206" /><p class="wp-caption-text">The New Yorker&#39;s website is a great example of how to use fonts effectively on the web.</p></div></p>
<p style="text-align: left;">The New Yorker uses images in order to display fonts.  Using font embedding effectively would save on bandwidth, since one font download could be used for all the headings on the page.</p>
<h2>Font formats supported</h2>
<p>Firefox 3.5+ , Safari 3.1+, Opera 10+ and Internet Explorer 4.0+ all support @font-face embedding (Google&#8217;s Chrome 3.0 beta does as well, but <a href="http://opentype.info/blog/2009/04/16/google-chrome-with-webfonts-support/">users will have to start it up in a special mode to make it work</a> in the short term).  They all support the use of <a title="Wikipedia TrueType entry" href="http://en.wikipedia.org/wiki/TrueType">TrueType</a> (.ttf) and <a title="Wikipedia OpenType entry" href="http://en.wikipedia.org/wiki/OpenType">OpenType</a> (.otf) fonts &#8230; <strong>except</strong> for Internet Explorer which only supports the proprietary <a title="Wikipedia Embedded OpenType entry" href="http://en.wikipedia.org/wiki/Embedded_Open_Type">Embedded Open Type</a> (.eot) format.  There aren&#8217;t as many fonts available in this format and the tool Microsoft gives out that converts .ttf fonts to .eot, called <a href="http://www.microsoft.com/typography/WEFT.mspx">WEFT</a>, is quite frustrating to use, and even crashes on Vista.  There is, however, an excellent command-line tool, <a href="http://code.google.com/p/ttf2eot/">ttf2eot</a>, that does a much better job. Both WEFT and ttf2eot only convert TrueType to Embedded Open Type &#8211; if you want to convert an <em>OpenType</em> font to Embedded Open Type, it is necessary to use <a href="http://fontforge.sourceforge.net/">FontForge</a>, a free font-editing tool, to convert the font to TrueType first, and then use ttf2eot to convert the resultant font to .eot format.  Although this method is roundabout and results in loss of detail due to the way the font formats store information, it is the only way I know to do this conversion.</p>
<p>For more detail on how to perform .eot font conversions using ttf2eot and FontForge, check out Edward O&#8217;Connor&#8217;s great article <cite><a href="http://edward.oconnor.cx/2009/07/how-to-create-eot-files-without-microsoft-weft">How to create EOT files without Microsoft WEFT</a></cite></p>
<h2>Where to get fonts you can legally use in web pages.</h2>
<p>Although it is now technically possible to embed almost any font inside a web page, it is important to remember that if you use a commercial font for this purpose, you must have a license to do this.  Since putting a font on a website will allow anyone on the Web to download it, a lot of font foundries currently do not allow their fonts to be used for web page embedding. It is for this reason that the browser vendors have been reluctant to implement this technology into their products until recently (font embedding is part of the CSS2 specification, which has been around since 1998).</p>
<p>Luckily, there are a few sites that are sprouting up that have done the initial work for you by listing fonts that allow font embedding on web pages legally.  The ones that I have visited include:</p>
<ul>
<li><a href="http://www.fontsquirrel.com">Font Squirrel&#8217;s</a> <a href="http://www.fontsquirrel.com/fontface">@font-face page</a>, which include @font-face kits that include an .eot as well as an .otf or .ttf font.  Each kit also includes <strong></strong>a stylesheet which can be linked directly into your document so you can use the font with minimal coding.</li>
<li><a href="http://www.smashingmagazine.com/">Smashing Magazine&#8217;s</a> has an excellent article, <cite><a href="http://www.smashingmagazine.com/2007/11/08/40-excellent-freefonts-for-professional-design/">40+ Excellent Freefonts For Professional Design</a></cite></li>
<li><a href="http://kernest.com/">Kernest.com</a> hosts a whole slew of fonts that can be used for font-embedding.</li>
<li><a href="http://webfonts.info">Webfonts.info</a> has a page dedicated to <a href="http://webfonts.info/wiki/index.php?title=Fonts_available_for_%40font-face_embedding">fonts available for @font-face embedding</a>.</li>
</ul>
<p>Note that whenever you use <strong>any</strong> font, make sure you check the license that comes with it.  Some fonts, even if their license allows for font embedding, may not allow you to use it for commercial purposes.  Others may, but only for a fee.  To be safe, check the documentation that comes with the font.</p>
<h2>How to insert a font into your webpage</h2>
<p>Once you have a font that you&#8217;d like to insert into your webpage, you first have to declare it inside your CSS stylesheet:</p>
<blockquote class="code">
<pre>@font-face {
	font-family: 'Droid Sans';

        /* for IE */
	src: url('/shared/fonts/DroidSans/DroidSans.eot');

        /*
         * for non-IE: first see if the font exists locally on the browser's
         * computer.  If so, use that copy of the font.  Otherwise, load it
         * from the server
         */
	src: local('Droid Sans'),
	     url('/shared/fonts/DroidSans/DroidSans.ttf') format('truetype');
}</pre>
</blockquote>
<p>It is very important to note here that <strong>order counts</strong>.  There are variations of this CSS syntax, but I have settled on this syntax for the reasons described in Paul Irish&#8217;s article <a href="http://paulirish.com/2009/bulletproof-font-face-implementation-syntax/">Bulletproof @font-face syntax</a>.</p>
<p>After you declare the font, you can use it inside any of your selectors as you would use any other font:</p>
<blockquote class="code">
<pre>body {
     font-family: "Droid Sans", "Arial", "Helvetica", sans-serif;
}</pre>
</blockquote>
<p>Note that it is still necessary to use alternative fonts &#8211; this is so that user agents that don&#8217;t support @font-face will still show an appropriate, similar looking font.</p>
<p>Some font families are contained in not just one file.  For example, Droid Sand  has a bold variant that is stored in a separate TrueType file (the .eot file used by Internet Explorer in the above example contains both the regular and bold variants).  The bold variant of Droid Sans can be declared correctly in your stylesheet like this:</p>
<blockquote class="code">
<pre>@font-face {
	font-family: 'Droid Sans';
	src: url('/shared/fonts/DroidSans/DroidSans.eot');
	src: local('Droid Sans'),
	     local('Droid Sans'),
	     url('/shared/fonts/DroidSans/DroidSans.ttf') format('truetype');
}

/* Bold declaration only for non-IE browsers */
@font-face {
	font-family: 'Droid Sans';
	src: local('Droid Sans Bold'),
	     local('Droid Sans-Bold'),
	     url('/shared/fonts/DroidSans/DroidSans-Bold.ttf') format('truetype');
	font-weight: bold;
}</pre>
</blockquote>
<h2>Browser Differences</h2>
<p>To effectively illustrate how differently browsers render embedded fonts, let&#8217;s compare them side by side:</p>
<table border="0">
<thead>
<tr>
<th></th>
<th>Safari 3</p>
<p>Windows</th>
<th>Firefox 3.5</p>
<p>Windows</th>
<th>Explorer 6</p>
<p>Windows</th>
</tr>
</thead>
<tbody>
<tr>
<th>Title of this blog post</th>
<td><img title="Screenshot Detail 1 (Safari)" src="http://www.useragentman.com/blog/wp-content/uploads/2009/09/safari-font-11.png" alt="Screenshot Detail 1 (Safari)" /></td>
<td><img title="Screenshot Detail 1 (Firefox)" src="http://www.useragentman.com/blog/wp-content/uploads/2009/09/firefox-font-12.png" alt="Screenshot Detail 1 (Firefox)" /></td>
<td><img title="Screenshot Detail 1 (IE)" src="http://www.useragentman.com/blog/wp-content/uploads/2009/09/ie-font-11.png" alt="Screenshot Detail 1 (IE)" /></td>
</tr>
<tr>
<th>Close-up of the title of this blog post</th>
<td><img title="Screenshot Closeup 1a (Safari)" src="http://www.useragentman.com/blog/wp-content/uploads/2009/09/safari-font-1-detail2.png" alt="Screenshot Closeup 1a (Safari)" /></td>
<td><img title="Screenshot Closeup 1a (Firefox)" src="http://www.useragentman.com/blog/wp-content/uploads/2009/09/firefox-font-1-detail.png" alt="Screenshot Closeup 1a (Firefox)" /></td>
<td><img title="Screenshot Closeup 1a (IE)" src="http://www.useragentman.com/blog/wp-content/uploads/2009/09/ie-font-1-detail.png" alt="Screenshot Closeup 1a (IE)" /></td>
</tr>
<tr>
<th>Subheading from this blog post</th>
<td><img title="Screenshot Detail 2 (Safari)" src="http://www.useragentman.com/blog/wp-content/uploads/2009/09/safari-font-1-detail1.png" alt="Screenshot Detail 2 (Safari)" /></td>
<td><img title="Screenshot Detail 2 (Firefox)" src="http://www.useragentman.com/blog/wp-content/uploads/2009/09/firefox-font-2.png" alt="Screenshot Detail 2 (Firefox)" /></td>
<td><img title="Screenshot Detail 2 (IE)" src="http://www.useragentman.com/blog/wp-content/uploads/2009/09/ie-font-2.png" alt="Screenshot Detail 2 (IE)" /></td>
</tr>
<tr>
<th>Close-up of subheading of this blog post</th>
<td><img title="Screenshot Closeup 2 (Safari)" src="http://www.useragentman.com/blog/wp-content/uploads/2009/09/safari-font-2-detail.png" alt="Screenshot Closeup 2 (Safari)" /></td>
<td><img title="Screenshot Closeup 2 (Firefox)" src="http://www.useragentman.com/blog/wp-content/uploads/2009/09/firefox-font-2-detail.png" alt="Screenshot Closeup 2 (Firefox)" /></td>
<td><img title="Screenshot Closeup 2 (IE)" src="http://www.useragentman.com/blog/wp-content/uploads/2009/09/ie-font-2-detail.png" alt="Screenshot Closeup 2 (IE)" /></td>
</tr>
<tr>
<th>Close-up of main text of this blog post</th>
<td><img title="Screenshot Closeup 3 (Safari)" src="http://www.useragentman.com/blog/wp-content/uploads/2009/09/safari-3-detail.png" alt="Screenshot Closeup 3 (Safari)" /></td>
<td><img title="Screenshot Closeup 3 (Firefox)" src="http://www.useragentman.com/blog/wp-content/uploads/2009/09/firefox-3-detail.png" alt="Screenshot Closeup 3 (Firefox)" /></td>
<td><img title="Screenshot Closeup 3 (IE)" src="http://www.useragentman.com/blog/wp-content/uploads/2009/09/ie-3-detail.png" alt="Screenshot Closeup 3 (IE)" /></td>
</tr>
</tbody>
</table>
<p>As you may see, there are some slight differences in the way that fonts are rendered in the various browsers:</p>
<ul>
<li><strong>Fonts displayed on Safari for Windows (and all browsers on the Mac) in my opinion look the nicest</strong>: they are nicely smoothed out and the text is quite easily read at smaller sizes.  This is due to the way Apple products render fonts.  <a title="Joel Spolsky article &quot;Font smoothing, anti-aliasing, and sub-pixel rendering&quot;" href="http://www.joelonsoftware.com/items/2007/06/12.html">Apple has always differed in philosophy with Microsoft on how to render fonts</a>, and this difference is quite obvious when testing pages under the Windows operating system.</li>
<li><strong>I have found that Internet Explorer does a poor job when displaying fonts converted from OpenType</strong> — the glyphs tend to be more jagged and some elements tend to be rendered thinner than they should be. GrauBlau Web, the font used in the headings of  this page, is a converted OpenType font, and you can see this effect in the close-ups above. It does not occur in the main body of the text because Droid Sans is a TrueType font.  There seems to be two reasons for this:
<ol>
<li>There was information loss when converting GrauBlau Web from OpenType to TrueType.</li>
<li>In Explorer, <a href="http://en.wikipedia.org/wiki/ClearType">ClearType</a> renders this font using subpixel anti-aliasing quite more severely than Safari, while other Windows browsers use vanilla anti-aliasing to get the job done.  A <a href="http://www.luxography.com/">friend of mine</a> pointed this out, and he said that it&#8217;s because ClearType renders TrueType (and, it seems, Embedded Open Type) fonts with subpixel anti-aliasing, but OpenType for some reason isn&#8217;t.  I don&#8217;t know the reasons why, but in this example it looks like it is true &#8211; if you look at all of the Explorer closeups,you&#8217;ll see the coloured pixels on the edge of all the glyphs, while in Firefox only Droid Sans (which is a TrueType font) has them.</li>
</ol>
</li>
<li><strong>Firefox only allows you to embed fonts that come from the same server</strong>, unless some special headers appear in the HTTP server response.  Also, unlike the other browsers, <strong>Firefox users first see the page without the embedded font <em>until</em> the font is loaded completely</strong>, at which time the fonts suddenly appear on the page. While it can be argued that this is a good thing (the user can read the content immediately without having to rely on the special font), this may not what a web designer would consider desirable.</li>
</ul>
<p>There are a few more differences, which are better outlined at the <a href="http://webfonts.info/wiki/index.php?title=Main_Page">Web Fonts</a> Wiki, which seems to keep its information up-to-date.</p>
<h2>How to choose which fonts to use</h2>
<p>Not having gone to design school, I cannot claim to be an authority on this subject, but I think it is safe to say that when choosing the fonts that you are going to use, it should be in sync with the mood and message you want readers to experience.  Chuck Green&#8217;s article, <a href="http://www.ideabook.com/tutorials/typography/type_palettes.html">Type palettes</a>, goes into more depth on this subject, and Michael Martin of Smashing Magazine has a great article about <a href="http://www.smashingmagazine.com/2009/08/20/typographic-design-survey-best-practices-from-the-best-blogs/">Typographic Design Patterns and Best Practices</a>.  Although both of these articles don&#8217;t go into font-embedding specifically, they are still relevant reading.</p>
<p>It took me a long time to decide on the fonts I have used here on my blog. When designing the layout, I was going for two things:</p>
<ol>
<li>I wanted the body text to be easy to read</li>
<li>I wanted the feeling of the whole blog to be friendly and not look like an academic paper</li>
</ol>
<p>In the end I decided to use:</p>
<ol>
<li><a href="http://www.fonts.info/info/press/free-fonts-for-font-face-embedding.htm">GrauBlau Web</a> for the headers because it is narrow (which allows more text on a line), easy on the eyes, and since it is used on headers, the user notices it right away and thinks &#8220;Hey, this looks different!&#8221;.</li>
<li><a href="http://www.droidfonts.com/info/droid-sans-fonts/">Droid Sans</a> for the main text because it was designed to be easy to read even on low resolutions and, in combination with GrauBlau Web, gave the site a nice, pleasant and friendly look.</li>
<li><a href="http://www.droidfonts.com/info/droid-sans-mono-fonts/">Droid Sans Mono</a> for the code listings since it was designed to compliment Droid Sans, and, I believe, looks a jillion times better than Courier (which everyone up to now has been forced to use due to a lack of nice looking monospace fonts installed on most computers today).</li>
</ol>
<p>Again, I didn&#8217;t go to design school, but I think for the type of site this is (a blog about web technology), it suits its purpose rather well.   I <strong>was</strong> tempted to choose more ornate fonts, but I didn&#8217;t think they suited the content.</p>
<h2>Optimizing Font Files</h2>
<p>Sometimes you may find that the font files are a little larger than you&#8217;d like.  If you open up the font file in <a href="http://fontforge.sourceforge.net/">FontForge</a>, you may find that a lot of the glyphs inside are not necessary for what you are doing (for example, if your pages are all in English, you might not want all the accented characters that the font contains).  Use FontForge to delete the glyphs you don&#8217;t need and regenerate the font &#8211; you&#8217;ll see that you save quite a few kilobytes, especially in a Unicode font with lots of Japanese and Russian characters included.</p>
<p>Again, because of licensing issues, please ensure that the font license allows you to edit the font in this manner.</p>
<h2>Conclusion</h2>
<p>What is written here is just the tip of the iceberg.  In the next few years, I expect to be reading several articles on the best way to use embedded fonts, from technical, usability, internationalization and design perspectives. Unfortunately, I also expect to see a lot of MySpace pages looking uglier than ever.  Imagine! Now, teenagers around the world can have animated backgrounds, Black Eyed Peas songs playing on load, <strong>and</strong> have that <a href="http://www.fontsquirrel.com/fonts/junkos-typewriter">crazy typewriter font</a> on the main copy.</p>
<p>My God, what have we done &#8230;.</p>
<div id="_mcePaste" style="overflow: hidden; position: absolute; left: -10000px; top: 1368px; width: 1px; height: 1px;">http://webfonts.info/wiki/index.php?title=Fonts_available_for_%40font-face_embedding</div>
]]></content:encoded>
			<wfw:commentRss>http://www.useragentman.com/blog/2009/09/20/font-face-in-depth/feed/</wfw:commentRss>
		<slash:comments>67</slash:comments>
		</item>
	</channel>
</rss>

