<?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; XML</title>
	<atom:link href="http://www.useragentman.com/blog/category/technologies/xml/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>Clipping JPEG Images Into Non-Rectangular Polygons Using polyClip.js</title>
		<link>http://www.useragentman.com/blog/2011/10/29/clipping-jpeg-images-into-non-rectangular-polygons-using-polyclip-js/</link>
		<comments>http://www.useragentman.com/blog/2011/10/29/clipping-jpeg-images-into-non-rectangular-polygons-using-polyclip-js/#comments</comments>
		<pubDate>Sat, 29 Oct 2011 15:20:29 +0000</pubDate>
		<dc:creator>zoltan</dc:creator>
				<category><![CDATA[canvas]]></category>
		<category><![CDATA[HTML5]]></category>
		<category><![CDATA[Images]]></category>
		<category><![CDATA[JavaScript]]></category>
		<category><![CDATA[jQuery]]></category>
		<category><![CDATA[Uncategorized]]></category>
		<category><![CDATA[VML]]></category>
		<category><![CDATA[arbitrary clipping]]></category>
		<category><![CDATA[clipping]]></category>
		<category><![CDATA[non-rectangular clipping. polygon clipping]]></category>
		<category><![CDATA[polyClip]]></category>
		<category><![CDATA[polygon]]></category>

		<guid isPermaLink="false">http://www.useragentman.com/blog/?p=3526</guid>
		<description><![CDATA[<img src="http://www.useragentman.com/blog/wp-content/uploads/2011/10/scissorsTeaser.jpg" /> Up until now, if a developer needed to clip an image in a non-rectangular shape, it was necessary to save the image as a PNG with an alpha channel. If the image is a photograph, the file-size balloons up to unacceptable levels. My new library, polyClip.js, allows developers to clip these images using photograph friendly JPEGs instead. This article guides you step by step on how to use it yourself.]]></description>
			<content:encoded><![CDATA[<div class="box">
<div id="explanation1">This photo is not a PNG image with an alpha channel.</div>
<div id="explanation2"><a href="http://www.useragentman.com/blog/wp-content/uploads/2011/10/scissors.jpg">It is a JPEG</a> that has been clipped with polyClip.js</div>
<div id="explanation3">
<p>The text was rotated using CSS3 Transforms, with alternate CSS for older IE using the <a href="http://www.useragentman.com/IETransformTranslator">IE Transform Translator</a>.  Original photo by <a href="http://www.flickr.com/photos/free-stock/4816852597/">Emilian Robert Vicol</a> clipped with polyClip.js</p>
</p></div>
<div class="clipParent"><img data-polyclip=" 0,0,45,3,55,8,64,18,74,24,80,32,86,45,82,32,83,38,86,46,88,52,90,62,90,68,91,76,91,82,91,83,103,87,112,91,121,97,127,102,133,106,136,112,138,116,139,121,139,122,147,125,154,127,163,129,178,131,190,132,204,132,210,131,225,124,286,107,332,96,370,88,401,83,425,79,450,76,457,77,456,80,446,85,430,91,406,99,383,108,365,114,352,119,384,117,416,116,453,114,472,113,474,113,472,118,446,126,419,132,390,138,362,144,343,148,307,153,282,157,266,159,245,160,234,160,219,160,209,163,198,167,182,175,170,183,158,194,156,195,157,201,157,204,157,204,157,210,153,219,148,229,143,236,137,244,132,250,124,258,118,263,113,267,98,276,87,281,77,283,0,284,1,191,10,190,16,191,20,191,21,192,28,191,37,190,39,189,38,190,40,190,48,190,53,191,57,191,69,188,77,187,91,183,109,179,127,173,146,166,162,158,173,153,158,151,144,150,127,151,105,152,86,154,66,157,53,160,49,161,46,165,44,167,41,168,33,168,28,167,28,166,21,170,16,171,11,171,4,170,0,168" src="http://www.useragentman.com/blog/wp-content/uploads/2011/10/scissors.jpg" alt=""  width="480" height="360" class="alignleft size-full wp-image-3771" /></div>
</div>
<p>There have been many times I have come across the need to <strong>take an image and cut an irregular shape out of it.</strong>  Normally, when a developer comes across this requirement, the only thing to do is to open the image up with your favorite graphics editor, use the select tool to cut out the shape you want, and then save the result as a <a href="http://en.wikipedia.org/wiki/Portable_Network_Graphics">PNG</a>, since it is the only image format used by all web browsers that support alpha channels.  The problem is that <strong>PNG images, while compressed, are not as small as <a href="http://en.wikipedia.org/wiki/Jpeg">JPEGs</a> if the source image is a photograph</strong>, and the download time of a page can balloon to unacceptable levels if there are many of these types of image on a page.  When I first came across this problem, I didn&#8217;t think there was an obvious solution, but after a lot of thought, I created <strong>a library that uses <a href="http://en.wikipedia.org/wiki/HTML_canvas">HTML5 <code>canvas</code></a> to clip a JPEG </strong> (or any other image for that matter).  <strong>The library also supports older versions of IE</strong> (7-8) using the <a href="http://excanvas.sourceforge.net/">Excanvas JavaScript library</a> which polyfills <code>canvas</code> using <a href="http://en.wikipedia.org/wiki/Vector_Markup_Language">VML</a>.</p>
<h2>Okay, How Can I Do The Same Thing?</h2>
<ul>
<li><a href="https://github.com/zoltan-dulac/polyClip">Download my script from github</a> (It includes jQuery 1.6.4 and excanvas release 3.  It should work with later versions &mdash; if it doesn&#8217;t, please let me know and I&#8217;ll fix it ;-) ) .</li>
<li>Include them into the head of your document.<br />
<blockquote class="code">
<pre>
  &lt;script src="/path/to/js/jquery-1.6.2.min.js"&gt;&lt;/script&gt;

  &lt;!--[if lt IE 9 ]&gt;
   &lt;script src="/path/to/js/excanvas/excanvas.compiled.js"&gt;&lt;/script&gt;
  &lt;![endif]--&gt;

  &lt;script src="/path/to/js/polyClip-p.js"&gt;&lt;/script&gt;
</pre>
</blockquote>
</li>
<li>Layout your page as normal, placing <code>img</code> tags where you want the clipped images to go:<br />
<blockquote class="code">
<pre>
&lt;div class="clipParent"&gt;
  &lt;img src="images/image.jpg" /&gt;
&lt;/div&gt;
</pre>
</blockquote>
<p><strong>Note the <code>div</code> tag with the class of <code>clipParent</code></strong>.  You must surround all the image tags with <code>data-polyclip</code> attributes set one.  This is so you can style the image correctly, since the library will remove the image tag and replace it with a <code>canvas</code> element.
</p></blockquote>
</li>
<li>For every image on your page that you want to clip, calculate the points of the shape you want to cut out of the image and place them in the <code>data-polyclip</code> attribute.  For example, let&#8217;s say you have the following shape you want to cut out of a photograph:
<div class="centered ghost">
  <img src="/tests/polyClip/images/crop.jpg"   />
</div>
<div class="clipParent centered inFront">
  <img src="/tests/polyClip/images/crop.jpg" data-polyclip="487, 4, 500, 239, 19, 239, 43, 195" data-stroke="rgb(0, 0, 0)" /></p>
<div class="point" id="pt1" style="left: 487px; top: 4px; "><span>(487, 4)</span></div>
<div class="point" id="pt2" style="left: 500px; top: 239px"><span>(500, 239)</span></div>
<div class="point" id="pt3" style="left: 19px; top: 239px"><span>(19, 239)</span></div>
<div class="point" id="pt4" style="left: 43px; top: 195px; "><span>(43, 195)</span></div>
</div>
<p>You would then just set the <code>data-polyclip</code> attribute to those points:</p>
<blockquote class="code">
<pre>
&lt;img src="image.jpg" <span class="hilite">data-polyclip="487, 4, 500, 239, 19, 239, 43, 195"</span> /&gt;
</pre>
</blockquote>
<p>Note that the point co-ordinates are comma delimited.  If you don&#8217;t want to calculate these numbers by hand, you can use your favorite imagemap generation tool to do generate the list of coordinates.  Just remember to take the coordinates out of the imagemap code and stick it in the <code>data-polyclip</code> attribute (for the examples on this page, I used the on-line tool available at <a href="http://www.image-maps.com">image-maps.com</a>).</li>
</ul>
<h2>Why Should I Do This Instead of Using a PNG?</h2>
<p>Compare the image above with a PNG clipped with the GIMP.   Even when I compressed the PNG with <a href="http://www.useragentman.com/blog/2009/09/16/optimizing-png-files-for-both-web-and-print/">my PNG optimization script</a>, the 191K PNG file is huge compared to it&#8217;s tiny 18K polyclipped JPEG analogue (<strong>Note:</strong> file sizes refer to the size of the full image as displayed at the top of this article):</p>
<table class="dataTable">
<thead>
<tr>
<th>JPG using polyClip.js (18K)</th>
<th>PNG (191K)</th>
</tr>
</thead>
<tbody>
<tr>
<td>
<div class="clipParent"><img data-polyclip="0,0,55,0,64,4,70,12,80,22,82,32,86,45,82,32,83,38,86,46,88,52,90,62,90,68,91,76,91,82,91,83,103,87,112,91,121,97,127,102,133,106,136,112,138,116,139,121,139,122,147,125,154,127,163,129,178,131,190,132,204,132,210,131,225,124,286,107,332,96,370,88,401,83,425,79,450,76,457,77,456,80,446,85,430,91,406,99,383,108,365,114,352,119,384,117,416,116,453,114,472,113,474,113,472,118,446,126,419,132,390,138,362,144,343,148,307,153,282,157,266,159,245,160,234,160,219,160,209,163,198,167,182,175,170,183,158,194,156,195,157,201,157,204,157,204,157,210,153,219,148,229,143,236,137,244,132,250,124,258,118,263,113,267,98,276,87,281,77,283,0,284,1,191,10,190,16,191,20,191,21,192,28,191,37,190,39,189,38,190,40,190,48,190,53,191,57,191,69,188,77,187,91,183,109,179,127,173,146,166,162,158,173,153,158,151,144,150,127,151,105,152,86,154,66,157,53,160,49,161,46,165,44,167,41,168,33,168,28,167,28,166,21,170,16,171,11,171,4,170,0,168" src="http://www.useragentman.com/blog/wp-content/uploads/2011/10/scissors.jpg" alt=""  width="480" height="360" class="alignleft size-full wp-image-3771" /></div>
</td>
<td>
<div class="pngImage">
  <img src="http://www.useragentman.com/blog/wp-content/uploads/2011/10/scissors.png" />
  </div>
</td>
</tr>
</tbody>
</table>
<p>You may ask whether the amount of JavaScript used in this solution is greater than the bandwidth saved by using JPEG compression.  <strong>Not including jQuery, the amount of JavaScript clocks in at 2K or 13K</strong>, depending on the browser used (2K for the compressed polyClip script and 11K for excanvas, which will only be loaded by IE7-8). Although jQuery adds 91K to this equation, it doesn&#8217;t matter that much to me personally since I am probably using it for other parts of my page anyways.  <strong>Even with jQuery, the amount of JavaScript downloaded outweighs using a PNG,</strong> especially if your are clipping a larger image or a huge amount of smaller images.</p>
<p><a class="exampleLink" href="https://github.com/zoltan-dulac/polyClip">Download the latest version of polyClip.js from github.</a></p>
<h2>A Few Caveats</h2>
<ul>
<li>In IE7 and 8, the image may appear briefly as a black outline before the image appears. Other than that, it looks about the same as the other browsers.</li>
<li>The image does not show up correctly in Opera Mini.  Then again, a lot of things (e.g. CSS3 text-shadows, CSS3 Transforms, etc.) don&#8217;t show up correctly in Opera Mini. :-)</li>
</ul>
]]></content:encoded>
			<wfw:commentRss>http://www.useragentman.com/blog/2011/10/29/clipping-jpeg-images-into-non-rectangular-polygons-using-polyclip-js/feed/</wfw:commentRss>
		<slash:comments>8</slash:comments>
		</item>
		<item>
		<title>Configuring JavaScript Applications With XML</title>
		<link>http://www.useragentman.com/blog/2009/10/27/configuring-javascript-applications/</link>
		<comments>http://www.useragentman.com/blog/2009/10/27/configuring-javascript-applications/#comments</comments>
		<pubDate>Wed, 28 Oct 2009 02:37:54 +0000</pubDate>
		<dc:creator>admin</dc:creator>
				<category><![CDATA[JavaScript]]></category>
		<category><![CDATA[XML]]></category>

		<guid isPermaLink="false">http://www.useragentman.com/blog/?p=71</guid>
		<description><![CDATA[I have been hacking JavaScript for close to 12 years now, and love it.  But just like anyone you have been enamored with for a long time, there are bound to be things that drive you crazy about the object of your affection.  Sure, your feelings are stronger than when you first met, but sometimes, [...]]]></description>
			<content:encoded><![CDATA[<p><img class="size-full wp-image-283 alignleft whiteImage" title="configurationXML" src="http://www.useragentman.com/blog/wp-content/uploads/2009/10/configurationXML.png" alt="Remixed from an image from the Open Clip Art Library" width="250" height="89" /></p>
<p>I have been hacking JavaScript for close to 12 years now, and love it.  But just like anyone you have been enamored with for a long time, there are bound to be things that drive you crazy about the object of your affection.  Sure, your feelings are stronger than when you first met, but sometimes, after you&#8217;ve had an a disagreement after a late night of coding, you catch yourself thinking “why in the world does she do things that way!?! Ridiculous!  She is driving me crazy with her inflexibility!”  You then calm down, and realize that despite her flaws, she is still the exciting, cool and can&#8217;t-live-without-her girl she was when you first met her – maybe even more so.</p>
<p>Okay, I don&#8217;t mean to equate JavaScript with my wife (that may result with me sleeping on the couch tonight).  But sometimes the way JavaScript does things is pretty silly.  You&#8217;d figure after all these years, some of these things would have changed, but they haven&#8217;t.</p>
<h2>Long Strings in JavaScript</h2>
<p>Take for example the way that JavaScript likes to handle long, multi-line strings:</p>
<blockquote class="code">
<pre>var html = "&lt;thead&gt;&lt;tr&gt;&lt;th&gt;Name&lt;/th&gt;&lt;th&gt;Address&lt;/th&gt;&lt;th&gt;City&lt;/th&gt;" +
"&lt;th&gt;Province&lt;/th&gt;&lt;th&gt;Postal Code&lt;/th&gt;&lt;th&gt;Telephone&lt;/th&gt;&lt;/tr&gt;&lt;/thead&gt;";</pre>
</blockquote>
<p>Concatenating strings is a pretty expensive operation, both in <a title=" String Performance: an Analysis" href="http://www.sitepen.com/blog/2008/05/09/string-performance-an-analysis/">memory and processing time</a>, and using concatenation  it to describe a constant string doesn&#8217;t make too much sense.  But putting this string on one line would make the code quite unwieldy to read.  Plus it looks ugly.  I may be a slob in real life (my coworkers and my family could go on for hours about that one) , but I love my code neat.</p>
<h2>Hard-Coding Values into Scripts</h2>
<p>Another problem I have with this method of defining strings is that we are hard-coding text into the script. This is not a problem unique to JavaScript by any means, but this breaks the <a title="Wikipedia article on Unobtrusive JavaScript" href="http://en.wikipedia.org/wiki/Unobtrusive_JavaScript">Structure/View/Behaviour separation</a> model that I like to follow when I code a web application.  Furthermore, if we had two pages with the same content but written in different languages (like in Canada, where a lot of sites are in English and French) we either have to have two versions of our script, or have the script broken into two parts: one with all the general code in it and one containing the language specific code.    While the latter is the more desirable of the two, it doesn&#8217;t lend itself to integrate well with some server-side web application frameworks like <a title="Java Struts home page." href="http://struts.apache.org/">Java Struts</a>.</p>
<p>Furthermore, I hate hard-coding <strong>any</strong> type of value (strings, integers, and any type of objects) directly into my scripts.  Scripts should be flexible enough to be used in any type of situation &#8211; your table pagination script may work well with having ten rows on the page at the time in one situation, but in another, you may want 15 or 20.</p>
<p>One comment I hear all the time is <strong>&#8220;Why not use JSON&#8221;?</strong> JSON is great, but because it is based on JavaScript, it is still gets ugly when manipulating long strings.</p>
<h2>Enter config.js to the Rescue</h2>
<p>In fact, it was Struts that inspired me to write the config.js JavaScript library.  If you aren&#8217;t familiar with it, Struts is a Java Framework that allows developers to configure their server-side web applications easily with a set of XML files.  It seemed natural to do the same in JavaScript, given all the DOM and XML processing routines that it has at its disposal, so I built config.js to do this task.  With this library, JavaScript developers can configure their own scripts using a block of XML.  This block of XML can be either embedded inside the HTML document (via an HTML comment) or in a separate XML file of its own.  And this configuration block can contain any number of strings, numbers, arrays or objects that a developer would need to get the job done.</p>
<p>For example, let&#8217;s say you had a JavaScript function that looked like this:</p>
<blockquote class="code">
<pre>function submitFormEvent(e){
  var amount = document.getElementById("amount").innerHTML;
  var creditCardType = document.getElementById("ccType").value;
  var month = document.getElementById("month").value;

  var configString = "Submitting this order will charge " + amount +
    " to your " + creditCardType +
    " and will be received on your " + month +
    " credit card bill.  Are you sure you want to do" +
    " this?");

  if (window.confirm(configString)) {
    window.location = "http://www.mycompany.com/myApp/chargeMe.do";
  }
  return;
}</pre>
</blockquote>
<p>As you can see, the English literals are hard-coded in the script and there is a lot of string concatenation going on.  One could refactor the script to use config.js to fix these issues  in four simple steps:</p>
<ol>
<li>Include the EventHelpers.js and config.js scripts in the &lt;head&gt; of your document (EventHelpers.js is included with the config.js archive):<br />
<blockquote class="code">
<pre>&lt;script type=”text/javascript” src=”/path/to/EventHelpers.js”&gt;&lt;/script&gt;
&lt;script type=”text/javascript” src=”/path/to/config.js”&gt;&lt;/script&gt;</pre>
</blockquote>
</li>
<li>Insert an XML block that contains the hard-coded strings in an HTML tag with an <code>id</code> of <code>config</code>:<br />
<blockquote class="code">
<pre>&lt;div id="config"&gt;
&lt;!--
&lt;config&gt;
  &lt;myApp&gt;
   &lt;confirmCharge&gt;
      &lt;text&gt;
Submitting this order will charge @amount@  to your
@creditCardType@ and will be received on your @month@
credit card bill.  Are you sure you want to do this?
      &lt;/text&gt;
      &lt;url&gt;http://www.mycompany.com/myApp/confirm.do&lt;/url&gt;
   &lt;/confirmCharge&gt;
  &lt;/myApp&gt;
&lt;/config&gt;
 --&gt;
&lt;/div&gt;</pre>
</blockquote>
</li>
<li>Refactor you code to use config.js routines:<br />
<blockquote class="code">
<pre>function submitFormEvent(e){
      var amount = document.getElementById("amount").innerHTML;
      var creditCardType = document.getElementById("ccType").value;
      var month = document.getElementById("month").value;
<strong>
      var configString = config.getScriptedValue(
          "myApp.confirmCharge.text",
          {
            amount: amount,
            creditCardType: creditCardType,
            month: month
          });

      if (window.confirm(configString)) {
          window.location = config.getValue("myApp.confirmCharge.url");
      }
</strong>
      return;
}</pre>
</blockquote>
</li>
<li>Replace any <code>window.onload</code> calls in your code with <code>config.addLoadEvent()</code> to ensure that any code that relies on config.js is initialized <strong>after</strong> the XML block is loaded into memory:<br />
<blockquote class="code">
<pre>config.addLoadEvent(exampleConfigForm.init);</pre>
</blockquote>
</li>
</ol>
<p>That&#8217;s it!  If you need to internationalize your application, use whatever internationalization framework your server side code uses &#8211; it should integrate well with config.js.  I use it with Java Struts all the time.</p>
<p><a class="exampleLink" href="/tests/config/example.html">See an example of the above code in action</a></p>
<h2>Use config.js in All Your Scripts</h2>
<p>Have more than one script on a page that you want to use config.js with?  No problem!  Add another block of XML inside the &lt;config&gt; node right after your other scripts config information:</p>
<blockquote class="code">
<pre>&lt;div id=”config”&gt;
&lt;!--
&lt;config&gt;
  &lt;myApp&gt;
   &lt;confirmCharge&gt;
      &lt;text&gt;
Submitting this order will charge @amount@  to your
@creditCardType@ and will be received on your @month@
credit card bill.  Are you sure you want to do this?
      &lt;/text&gt;
      &lt;url&gt;http://www.mycompany.com/myApp/confirm.do&lt;/url&gt;
   &lt;/confirmCharge&gt;
  &lt;/myApp&gt;

<span class="hilite">&lt;calendarWidget&gt;
  &lt;instructions&gt;Enter in a valid date after @dateBegin@&lt;/instructions&gt;
  &lt;errors&gt;
    &lt;notValid&gt;The date you entered is not valid&lt;/notValid&gt;
    &lt;holiday&gt;
Sorry, @date@ is a holiday and we won't be open
at that time.  Please try again.
    &lt;/holiday&gt;
  &lt;/errors&gt;
&lt;/calendarWidget&gt;
</span>
&lt;/config&gt;
--&gt;
&lt;/div&gt;</pre>
</blockquote>
<p>Now, all your configuration information for all your scripts can be in one place.  Programmers can now develop the code with place holders for the text, and not worry about accidentally messing up the code when marketing or customer service wants to make some textual changes.</p>
<h2>config.js can also handle HTML</h2>
<p>You can even insert full HTML inside the configuration XML block using a CDATA node:</p>
<blockquote class="code">
<pre>&lt;config&gt;
&lt;myApp&gt;
  &lt;browserWarning&gt;&lt;![CDATA[
    &lt;div class=”warning”&gt;
    As of @date@ we will &lt;strong&gt;not&lt;/strong&gt; be supporting Internet
    Explore 6 or lower.  Please &lt;a href=”/howToUpgradeIE.html"&gt;upgrade your
    installation of Internet Explorer&lt;/a&gt;, or install the latest version of one
    &lt;a href=”/otherChoices.html”&gt;the many alternative browsers available&lt;/a&gt;.
    &lt;/div&gt;
  ]]&gt;&lt;/browserWarning&gt;
  &lt;/myApp&gt;
&lt;/config&gt;</pre>
</blockquote>
<p>This makes using an HTML node&#8217;s .innerHTML property even more fun!  You longer do you have to hard-code  long chunks of HTML inside your scripts.  Try that with JSON!</p>
<h2>Framework Independent</h2>
<p>Config.js is not part of a JavaScript framework – you can use this library whether you use prototype, mootools, Dojo, jQuery or anything else that may come along.  Please feel free to make improvements and changes on it &#8211; if you submit the changes back to me, I&#8217;ll incorporate them into the next official release.</p>
<h2>More Information</h2>
<p>There is way more to config.js than is explained here.  Complete documentation for the library can be found here:<br />
<a class="exampleLink" href="/blog/config-js-–-a-javascript-cofiguration-library/">config.js manual page</a></p>
<h2>Download</h2>
<p>You can get full source here:</p>
<p><a class="exampleLink" href="/downloads/config.zip">config.js v.2.0 and example code (zip format)</a></p>
]]></content:encoded>
			<wfw:commentRss>http://www.useragentman.com/blog/2009/10/27/configuring-javascript-applications/feed/</wfw:commentRss>
		<slash:comments>0</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>
	</channel>
</rss>

