<?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>Web 3.0, 6 Bladed Razors, 7 Minute Abs &#187; font-face</title>
	<atom:link href="http://www.zachleat.com/web/tag/font-face/feed/" rel="self" type="application/rss+xml" />
	<link>http://www.zachleat.com/web</link>
	<description></description>
	<lastBuildDate>Fri, 09 Dec 2011 21:53:07 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	
		<item>
		<title>BigText Makes Text Big</title>
		<link>http://www.zachleat.com/web/bigtext-makes-text-big/</link>
		<comments>http://www.zachleat.com/web/bigtext-makes-text-big/#comments</comments>
		<pubDate>Wed, 12 Jan 2011 02:49:35 +0000</pubDate>
		<dc:creator>Zach Leatherman</dc:creator>
				<category><![CDATA[JavaScript]]></category>
		<category><![CDATA[Projects]]></category>
		<category><![CDATA[Typography]]></category>
		<category><![CDATA[3D Transforms]]></category>
		<category><![CDATA[BigText]]></category>
		<category><![CDATA[contenteditable]]></category>
		<category><![CDATA[Flexbox]]></category>
		<category><![CDATA[font-face]]></category>
		<category><![CDATA[jQuery UI]]></category>
		<category><![CDATA[Throttle]]></category>

		<guid isPermaLink="false">http://www.zachleat.com/web/?p=838</guid>
		<description><![CDATA[I like shortcuts:]]></description>
			<content:encoded><![CDATA[<p><em style="font-size: 90%">I like shortcuts: <a href="https://github.com/zachleat/BigText"">Fork BigText on Github</a> or <a href="/bigtext/demo/">Check out the BigText Demo Wizard</a></em></p>
<p>It all began with a simple web foray to <a href="http://designingmonsters.com/">Designing Monsters</a>.  Their simple, typographic design was beautiful. But why? Their combination of the beautiful League Gothic font, use of <a href="http://letteringjs.com/">Lettering.JS</a>, and some simple font scaling gave the page a wonderful consistent vertical alignment. Like the Million Dollar Homepage, I wanted to rebuild it &#8212; but I didn&#8217;t want to spend a lot of time manually adjusting font sizes. So I did what any programmer with the jQuery Golden Hammer would do, I turned my problem into a nail.</p>
<p><img src="http://www.zachleat.com/web/wp-content/uploads/2011/01/Screen-shot-2011-01-11-at-7.37.54-PM.png" alt="" title="The elusive BIGTEXT plugin exclusively caputured on film" width="287" height="332" class="alignright size-full wp-image-843" /><br />
At it&#8217;s simplest, the BigText jQuery plugin takes a single element and <strong>sizes the text inside of its child <code>&lt;div&gt;</code>s to fit the width of the parent elemen</strong>t.  Gives the text that lovely vertical alignment.</p>

<div class="wp_syntax"><div class="code"><pre class="html" style="font-family:monospace;">&lt;div id=&quot;bigtext&quot; style=&quot;width: 300px&quot;&gt;
    &lt;div&gt;The elusive&lt;/div&gt;
    &lt;div&gt;BIGTEXT&lt;/div&gt;
    &lt;div&gt;plugin exclusively&lt;/div&gt;
    &lt;div&gt;captured on film&lt;/div&gt;
&lt;/div&gt;</pre></div></div>


<div class="wp_syntax"><div class="code"><pre class="js" style="font-family:monospace;">$('#bigtext').bigtext();</pre></div></div>

<p>See <a href="http://jsfiddle.net/zachleat/WzN6d/">the above at JSFiddle</a>.</p>
<h3>Implementation Details</h3>
<p>The plugin itself is more than just a simple font-size incrementer.  I wasn&#8217;t happy with the performance of simply iterating through font sizes with a single fixed interval.  I decided it would be better to test multiple decreasing intervals.  For each line, it increments first by 16em until it detects a line break, backs off an interval then increments by <code>8em</code>. It continues with <code>4em</code>, <code>2em</code>, <code>1em</code>, <code>0.1em</code>, until it finds the correct <code>font-size</code> to the nearest hundredth of an em.  It&#8217;s noteworthy that Webkit does not respect font-sizes to the nearest hundredth, it&#8217;s precision is maxed out at tenths.  This algorithm results in fewer tests in most cases, especially where the resulting font-size will be very large. Performance is always important. After font-size, it moves to word-spacing as a backup for extra precision, especially needed on Webkit.</p>
<h2><em>The BigText Demo Wizard</em></h2>
<h3 style="text-align: center"><a href="/bigtext/demo/">Check out the Demo</a></h3>
<p>This is where the magic happens.</p>
<ul>
<li>Editable text (<code>contenteditable</code>), and BigText will run on every keyup event to resize what you&#8217;re typing.</li>
<li>Dynamic horizontal and vertical centering using <a href="http://infrequently.org/2009/08/css-3-progress/">Alex Russell&#8217;s Flex Box CSS classes</a> (This is easy now, hooray!)</li>
<li>3D transforms (browser support checked using <a href="http://www.modernizr.com/">Modernizr</a>, currently only available in Safari. Note: Chrome flattens to 2D space)</li>
<li>Custom fonts are loaded using <a href="http://code.google.com/apis/webfonts/docs/webfont_loader.html">Google&#8217;s Font Loader JavaScript API</a></li>
<li><a href="http://benalman.com/projects/jquery-throttle-debounce-plugin/">Ben Alman&#8217;s Throttle Plugin</a></li>
<li>The rest is mostly jQuery UI with the <a href="http://taitems.tumblr.com/post/482577430/introducing-aristo-a-jquery-ui-theme">Aristo theme</a></li>
</ul>
<p>Turns out, the <em>BigText Demo Wizard</em> makes for really easy <a href="http://vimeo.com/channels/kinetictypography">Kinetic Typography</a> screencasts (not amazing, but surely easy):</p>
<p><iframe class="youtube-player" type="text/html" width="640" height="385" src="http://www.youtube.com/embed/OuqB6e6NPRM" frameborder="0"><br />
</iframe></p>
<p>The above is simply the manual process of typing lyrics into the <em>BigText Demo Wizard</em>.  You can easily make one of these too, with the help of the following keyboard shortcuts:</p>
<ul style="font-size: 90%">
<li>CTRL + ALT + X: Set the text to a random 3D transform angle.</li>
<li>CTRL + ALT + C: Toggles between white and black background.</li>
<li>CTRL + ALT + R: Reset 3D to default state.</li>
<li><strong>CTRL + ALT + SPACE: Fade out current text, clears the text, sets a random 3D transform angle, ready to type!</strong></li>
<li>CTRL + ALT + ENTER: Same as CTRL + ALT + SPACE, but keeps the same 3D transform angle.</li>
</ul>
<p>The fun part about the <em>BigText Demo Wizard</em> for me was that it almost turned into a non-musical instrument when I used it real-time to complement music.  Feel free to cruise Pandora and type lyrics to the music until your wrists get sore. <strong>What can you make with it?</strong></p>
<p><em>The BigText Demo Wizard was tested manually in Safari 5, Chrome 8, Opera 11, Firefox 3.6, and Internet Explorer 8.  The BigText jQuery plugin has a full JsTestDriver suite, available on <a href="https://github.com/zachleat/BigText">GitHub</a>.  Just run <code>./test.sh</code> or <code>test.bat</code></em></p>
]]></content:encoded>
			<wfw:commentRss>http://www.zachleat.com/web/bigtext-makes-text-big/feed/</wfw:commentRss>
		<slash:comments>57</slash:comments>
		</item>
		<item>
		<title>The &#8220;24&#8243; Clock on ALARMd</title>
		<link>http://www.zachleat.com/web/the-24-clock-on-alarmd/</link>
		<comments>http://www.zachleat.com/web/the-24-clock-on-alarmd/#comments</comments>
		<pubDate>Sun, 24 Jan 2010 07:37:52 +0000</pubDate>
		<dc:creator>Zach Leatherman</dc:creator>
				<category><![CDATA[CSS]]></category>
		<category><![CDATA[Projects]]></category>
		<category><![CDATA[Alarmd]]></category>
		<category><![CDATA[font-face]]></category>

		<guid isPermaLink="false">http://www.zachleat.com/web/?p=465</guid>
		<description><![CDATA[If you&#8217;re only using @font-face for titles and text, you&#8217;re missing out on a whole wealth of use cases that have yet to be explored. For instance, I created a very simple 7 Segment Display Numeric font to be used for a skin on alarmd.com and changed the color using nothing but CSS to create [...]]]></description>
			<content:encoded><![CDATA[<p>If you&#8217;re only using @font-face for titles and text, you&#8217;re missing out on a whole <a href="http://www.zachleat.com/web/2010/01/03/css-sprites-using-font-face/">wealth of use cases</a> that have yet to be explored.  For instance, I created a very simple <a href="http://fontstruct.fontshop.com/fontstructions/show/282059">7 Segment Display Numeric font</a> to be used for a skin on <a href="http://www.alarmd.com/">alarmd.com</a> and changed the color using nothing but CSS to create the &#8220;24&#8243; Clock (true fans will note that the actual font is italic and <a href="http://www.panopticist.com/2006/05/there_is_something_weird_going_on_with_the_clock_on_24.php">has a serif on the 1</a>).  Nonetheless, this is just another useful application of @font-face.</p>
<p>Take a look at the <a href="http://www.fontsquirrel.com/fonts/list/style/Dingbat">Dingbats section on fontsquirrel</a> to get your brain going in the same direction.</p>
<p><img src="http://www.zachleat.com/web/wp-content/uploads/2010/01/Screen-shot-2010-01-24-at-1.22.39-AM.png" alt="" title="Screenshot of the 24 Clock on alarmd.com"/></p>
]]></content:encoded>
			<wfw:commentRss>http://www.zachleat.com/web/the-24-clock-on-alarmd/feed/</wfw:commentRss>
		<slash:comments>3</slash:comments>
		</item>
		<item>
		<title>DIY Webdings &#8211; CSS Sprites using @font-face</title>
		<link>http://www.zachleat.com/web/css-sprites-using-font-face/</link>
		<comments>http://www.zachleat.com/web/css-sprites-using-font-face/#comments</comments>
		<pubDate>Mon, 04 Jan 2010 00:48:29 +0000</pubDate>
		<dc:creator>Zach Leatherman</dc:creator>
				<category><![CDATA[CSS]]></category>
		<category><![CDATA[css-sprites]]></category>
		<category><![CDATA[font-face]]></category>

		<guid isPermaLink="false">http://www.zachleat.com/web/?p=433</guid>
		<description><![CDATA[Almost everyone knows the Webdings font or its sibling Wingdings. Even if you don&#8217;t, chances are pretty good that it&#8217;s installed on your system. Webdings is a symbol font designed in 1997 as a response to the need of Web designers for a fast and easy method of incorporating graphics in their pages. &#8230; Webdings [...]]]></description>
			<content:encoded><![CDATA[<p>Almost everyone knows the Webdings font or its sibling Wingdings.  Even if you don&#8217;t, chances are pretty good that it&#8217;s installed on your system.</p>
<blockquote><p>Webdings is a symbol font designed in 1997 as a response to the need of Web designers for a fast and easy method of incorporating graphics in their pages.<br />
&#8230;</p>
<p>Webdings is ideal for enriching the appearance of a Web page. Because it’s a font, it can be installed on the user’s system, (or embedded in the document itself) is fully scaleable [sic] and quick to render. It’s a perfect way of including graphics on your site without making users wait for lots of graphic files to download.</p>
<p> &#8211; Source <a href="http://www.microsoft.com/typography/fonts/family.aspx?FID=5">Microsoft Typography</a></p></blockquote>
<p>Microsoft was onto something here, and there is a nice parallel that can be drawn between the font and a CSS sprite: namely that multiple images are stored under the guise of a single HTTP request.  So, why not create our own font and use it as a CSS sprite?  Each character in the font (glyph) will be a single image in the sprite.</p>
<h2>Why is this awesome?</h2>
<ul>
<li>We can <strong>change the color</strong> of our font using nothing but CSS <code>color</code>.  This is a big one.  We don&#8217;t have to have separate images for hover states!  And if we want to change the color scheme, there are no new images to generate and we don&#8217;t have to make any changes to the font to do so.</li>
<li>Don&#8217;t have to monkey around with difficult to maintain CSS positioning code.</li>
<li>Fonts scale, graphics don&#8217;t.  Zooming in on a graphic will result in a pixelated image, but fonts will be smooth like a 6 blade razor shave.  Try zooming on the demo file below.</li>
</ul>
<h2>Why is this not awesome?</h2>
<ul>
<li>Font glyphs can only contain one color.</li>
<li>May experience the Flash of unstyled text (FOUT) while the font is loading.</li>
<li>Extra markup required for IE6 and IE7.  While @font-face is supported in all non-extinct versions of IE, each @font-face sprite requires a corresponding text character on the screen.  For instance, <code>&lt;span style="font-family: MyCustomFont;"&gt;A&lt;/span&gt;</code>, the A is required to display the @font-face Sprite stored under the A glyph.<br/><br />
Luckily, in most browsers we can inject a character using CSS :after/:before and the <code>content</code> property.  Unfortunately, this is <a href="http://www.quirksmode.org/css/beforeafter_content.html">not supported in IE6 or IE7</a>.  I haven&#8217;t investigated whether or not this might be solved using other means (CSS expressions) yet.</li>
<li>Safari asks for permission to use the font with a scary popup box, which I assume is a security precaution gleaned from the Windows Vista playbook.</li>
</ul>
<h2>Demo</h2>
<p>The following <a href="http://jquery-ui.googlecode.com/svn/trunk/tests/static/icons.html">jQuery UI Icons</a> are currently used in jQuery UI and are stored in <a href="http://jqueryui.com/themeroller/images/?new=888888&#038;w=256&#038;h=240&#038;f=png&#038;fltr[]=rcd|256&#038;fltr[]=mask|icons/icons.png">one big CSS sprite</a>.</p>
<p>It was pretty trivial to create <a href="http://fontstruct.fontshop.com/fontstructions/show/jquery_ui_icons_1">a font</a> with a subset of the jQuery UI icons (only the first 20, just a proof of concept here) using the wonderful <a href="http://fontstruct.fontshop.com/">FontStruct</a> utility.  Then, I took the TTF generated by FontStruct and plugged it into the completely lovely <a href="http://www.fontsquirrel.com/fontface/generator">FontSquirrel @font-face Kit Generator</a>.  That gave me everything I needed for a fully cross-browser test.</p>
<ul>
<li><a href="http://www.zachleat.com/test/fonts/font.html" style="font-size: 160%; font-weight: bold;">View the Demo</a></li>
</ul>
<p>Let me know what you think!</p>
<div style="font-size: 80%">
Successfully tested on:</p>
<ul>
<li>Google Chrome 4 (Mac)</li>
<li>Safari 4 (Mac)</li>
<li>Firefox 3.5 (Mac and Windows)</li>
<li>Internet Explorer 8</li>
<li>With documented limitations above:
<ul>
<li>Internet Explorer 6</li>
<li>Internet Explorer 7 (Compatibility Mode in IE8)</li>
</ul>
</li>
</ul>
<p>Does not work on (no @font-face support):</p>
<ul>
<li>Google Chrome 3 and prior</li>
<li>Firefox 3 and prior</li>
</ul>
</div>
<p>Read more about <a href="http://paulirish.com/2009/bulletproof-font-face-implementation-syntax/">@font-face support from Paul Irish</a>.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.zachleat.com/web/css-sprites-using-font-face/feed/</wfw:commentRss>
		<slash:comments>15</slash:comments>
		</item>
	</channel>
</rss>

