<?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>Threepress Consulting blog &#187; geek</title>
	<atom:link href="http://blog.threepress.org/category/geek/feed/" rel="self" type="application/rss+xml" />
	<link>http://blog.threepress.org</link>
	<description>Threepress creates software for publishers, educators and authors.</description>
	<lastBuildDate>Mon, 09 Jan 2012 13:02:39 +0000</lastBuildDate>
	<generator>http://wordpress.org/?v=2.9.2</generator>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
			<item>
		<title>Review: Meanwhile for iOS, by Jason Shiga &amp; Andrew Plotkin</title>
		<link>http://blog.threepress.org/2011/11/20/review-meanwhile-for-ios-by-jason-shiga-andrew-plotkin/</link>
		<comments>http://blog.threepress.org/2011/11/20/review-meanwhile-for-ios-by-jason-shiga-andrew-plotkin/#comments</comments>
		<pubDate>Sun, 20 Nov 2011 16:50:19 +0000</pubDate>
		<dc:creator>Liza Daly</dc:creator>
				<category><![CDATA[accessibility]]></category>
		<category><![CDATA[geek]]></category>
		<category><![CDATA[interactivity]]></category>

		<guid isPermaLink="false">http://blog.threepress.org/?p=2151</guid>
		<description><![CDATA[(Part of a new series of reviews of interactive digital fiction)

Meanwhile is a branched-storyline comic written and illustrated by Jason Shiga, originally published as a printed book. Interactive game developer Andrew Plotkin designed and coded the iOS version, available on the iOS App Store [iTunes link]. While I&#8217;ve seen the print edition, my first experience [...]]]></description>
			<content:encoded><![CDATA[<p><aside><em>(Part of a new series of reviews of interactive digital fiction)</em></aside></p>
<p><img src="http://3press-blog.s3.amazonaws.com/meanwhile1.png" width="400" alt="Screenshot of Meanwhile for iOS" /></p>
<p><cite>Meanwhile</cite> is a branched-storyline comic written and illustrated by Jason Shiga, originally published as a <a href="http://www.abramsbooks.com/Books/Meanwhile-9780810984233.html">printed book</a>. Interactive game developer Andrew Plotkin designed and coded the <a href="http://zarfhome.com/meanwhile/">iOS version</a>, available on the <a href="http://itunes.apple.com/us/app/meanwhile-for-ios/id458451517">iOS App Store</a> <small>[iTunes link]</small>. While I&#8217;ve seen the print edition, my first experience of the story was via the iOS app, as it will be for most readers.</p>
<h3>Story</h3>
<p><cite>Meanwhile</cite> is about a boy named Jimmy who buys some ice cream. Then things get complicated.</p>
<h3>Mechanics</h3>
<p>The comic is an infinite canvas; the app pans across the storyboard following the branching pathways. There&#8217;s a subtle rhythm in how the panels are laid out; sequences which happen quickly or follow naturally are clustered together in a single viewport. Surprise reveals, or shifts in time and place, are often in panels located far from their antecedent; the app reinforces this shift by swiftly panning across the story world. There&#8217;s an ever-present tension between this sense of place, and knowing that the canvas itself is too hopelessly tangled to really follow.</p>
<p><img src="http://3press-blog.s3.amazonaws.com/meanwhile4.png" width="400" alt="Screenshot of Meanwhile for iOS" /></p>
<h3>Design</h3>
<p>There was a moment in my first readthrough where I laughed out loud in surprise; the mechanics and the story clicked perfectly. An interactive narrative may begin life as a purely conceptual idea about form (&#8220;I&#8217;d like to tell a choose-your-own-adventure story as a comic book&#8221;). If it&#8217;s successful, it will just appear to have been the natural way to tell that story. Interactivity isn&#8217;t an add-on or an enhancement — it&#8217;s a genre in its own right, not substitutable with another method of expression.</p>
<p><img src="http://3press-blog.s3.amazonaws.com/meanwhile3.png" width="400" alt="Screenshot of Meanwhile for iOS" /></p>
<p><cite>Meanwhile</cite> is expertly paced — one of the hardest things to control in an interactive work. There&#8217;s a gentle opener (certainly a comic book should not need instructions), some set-up with intriguing foreshadowing, and then quickly &#8220;goes wide&#8221;, providing branch points which clearly lead to a variety of outcomes. </p>
<p>There are even a few puzzles to solve, a feat given the fact that the entire story is plainly visible. Puzzles mean the story isn&#8217;t simply about tapping through all the branches until you&#8217;ve exhausted the narrative tree.  Problem-solving provides narrative drive and consequences for failure; as a reader, I was motivated to succeed. (And discovering the &#8220;one path [that] will lead you to happiness and success&#8221; was particularly satisfying.)</p>
<h3>Tech notes</h3>
<p><small>Requires iOS 4.2+, 28.3MB</small></p>
<p><cite>Meanwhile</cite> is available for iPhone/iPod as well as iPad. I played on my iPhone, which feels more &#8220;right&#8221; to me than the larger viewport available on the iPad. Unfortunately the artwork is not high-res and looks a little grainy on a Retina screen; I&#8217;d love to see an update with new art.  There are subtle sound effects which I didn&#8217;t notice until a later playthrough; they aren&#8217;t necessary for the story and I happen to prefer my interactive works to be silent, so this is purely optional.</p>
<h4>Accessibility</h4>
<p>The application is also <em>accessible with VoiceOver</em>. Each panel has textual description of the depicted events and dialog, making it fully playable for visually-impaired users. Hooray!</p>
<p><a href="http://zarfhome.com/meanwhile/"><img src="http://3press-blog.s3.amazonaws.com/meanwhile2.png" width="400" alt="Screenshot of Meanwhile for iOS" /></a></p>
<p><strong>Conclusion: Highly recommended and well-worth  $4.99 USD.</strong></p>
]]></content:encoded>
			<wfw:commentRss>http://blog.threepress.org/2011/11/20/review-meanwhile-for-ios-by-jason-shiga-andrew-plotkin/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
		<item>
		<title>Caveman: An HTML5 cache manifest validator</title>
		<link>http://blog.threepress.org/2011/11/07/caveman-an-html5-cache-manifest-validator/</link>
		<comments>http://blog.threepress.org/2011/11/07/caveman-an-html5-cache-manifest-validator/#comments</comments>
		<pubDate>Mon, 07 Nov 2011 14:03:34 +0000</pubDate>
		<dc:creator>Liza Daly</dc:creator>
				<category><![CDATA[geek]]></category>
		<category><![CDATA[html5]]></category>
		<category><![CDATA[tools]]></category>

		<guid isPermaLink="false">http://blog.threepress.org/?p=2146</guid>
		<description><![CDATA[Over on his own blog, Ned Batchelder has written up his HTML5 appcache validator tool he whipped together while working on Ibis Reader:

The result is Caveman, a Python tool to validate HTML5 cache manifests. It scrapes the HTML page you specify, finding resources, then compares them to the cache manifest and reports problems.

Full blog post [...]]]></description>
			<content:encoded><![CDATA[<p>Over on his own blog, <a href="http://nedbatchelder.com/">Ned Batchelder</a> has written up his HTML5 appcache validator tool he whipped together while working on <a href="http://ibisreader.com/">Ibis Reader</a>:</p>
<blockquote>
<p>The result is <a href="http://nedbatchelder.com/code/caveman/">Caveman</a>, a Python tool to validate HTML5 cache manifests. It scrapes the HTML page you specify, finding resources, then compares them to the cache manifest and reports problems.</p>
</blockquote>
<p><a href="http://nedbatchelder.com/blog/201111/caveman.html">Full blog post</a> and <a href="http://nedbatchelder.com/code/caveman/">complete documentation on Caveman</a>.</p>
]]></content:encoded>
			<wfw:commentRss>http://blog.threepress.org/2011/11/07/caveman-an-html5-cache-manifest-validator/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>HTML5 drag and drop support now in Ibis Reader</title>
		<link>http://blog.threepress.org/2011/08/19/html5-drag-and-drop-support-now-in-ibis-reader/</link>
		<comments>http://blog.threepress.org/2011/08/19/html5-drag-and-drop-support-now-in-ibis-reader/#comments</comments>
		<pubDate>Fri, 19 Aug 2011 14:55:18 +0000</pubDate>
		<dc:creator>Liza Daly</dc:creator>
				<category><![CDATA[geek]]></category>
		<category><![CDATA[html5]]></category>
		<category><![CDATA[ibisreader]]></category>

		<guid isPermaLink="false">http://blog.threepress.org/?p=2097</guid>
		<description><![CDATA[HTML5 is a wild grab-bag of technologies.  One of the lesser-known bits at the bottom of the bag is the drag and drop API. This allows you to physically drag files from your computer into a browser page, and have the browser do something with the file (typically upload it).
If you&#8217;re logged in to [...]]]></description>
			<content:encoded><![CDATA[<p>HTML5 is a wild grab-bag of technologies.  One of the lesser-known bits at the bottom of the bag is the <a href="http://www.html5rocks.com/en/tutorials/dnd/basics/">drag and drop API</a>. This allows you to physically drag files from your computer into a browser page, and have the browser do something with the file (typically upload it).</p>
<p>If you&#8217;re logged in to <a href="http://ibisreader.com/">Ibis Reader</a> from a computer (not the mobile interface), you can now upload one or even many EPUB files at a time just by dragging.  Here&#8217;s how it looks in Chrome:</p>
<p><img src="http://3press-blog.s3.amazonaws.com/sm-ibis-drag-upload-dialog.png" alt="Dragging a file into the Ibis Reader window produces a dialog box inviting the user to let go and drop the file" /></p>
<p>This menu will open up on a &#8220;drag&#8221; event, meaning that you&#8217;ve moved some file from your desktop onto the Ibis Reader window.</p>
<p>When you &#8220;drop&#8221; the file into that space, a progress bar appears showing the upload time:</p>
<p><img src="http://3press-blog.s3.amazonaws.com/sm-ibis-drag-upload-progress.png" alt="Dropping the file will show a progress bar" /></p>
<p>This uses the HTML5 &lt;progress&gt; element on supported browsers.</p>
<p>When complete, you&#8217;ll be taken to your personal library of books and the new book will be at the top.</p>
<p>If there&#8217;s an error, you&#8217;ll see it on the upload dialog:</p>
<p><img src="http://3press-blog.s3.amazonaws.com/sm-ibis-drag-upload-error.png" alt="Trying to upload a non-EPUB file by dragging will show an error message" /></p>
<p>Try it with multiple files simultaneously!</p>
<h3>Support</h3>
<p>This should work in Firefox 5+ and recent versions of Chrome.  It doesn&#8217;t currently work in Safari 5.x.</p>
<p>For browsers which don&#8217;t support drag and drop yet we also improved the normal file upload method (in which you click &#8220;Add a Book&#8221; to upload by selecting a file from your computer).  The &#8220;Add a Book&#8221; feature now supports multiple file upload, so if you select multiple files from the dialog, it will upload them in succession.</p>
<p><img src="http://3press-blog.s3.amazonaws.com/sm-ibis-file-upload-multiple.png" alt="The file upload dialog now supports multiple files" /></p>
<p>This will work on Safari as well as other browsers which support multi-file upload.</p>
<p>In any scenario, if you upload multiple files and one has an error, the upload process will stop at that file (other files that came before will successfully be added to your library).</p>
<p>Enjoy!</p>
<h3>Tech details</h3>
<p>Safari 5 currently has a bug that prevents the &lt;progress&gt; element from being nested inside of a block-level element like a &lt;div&gt; (This was a WebKit bug whose fix just hasn&#8217;t made it into Safari yet.)  In Safari you may not see the progress bar because of this.</p>
<p>I would have preferred to let you drop the files <em>anywhere</em> on the site, rather than just in that big box, but Chrome requires that the drop point for file uploads be inside of a &lt;form&gt;.  You&#8217;ll see the same paradigm if you use Gmail&#8217;s drag and drop support for attachments (did you know you could do that?)</p>
]]></content:encoded>
			<wfw:commentRss>http://blog.threepress.org/2011/08/19/html5-drag-and-drop-support-now-in-ibis-reader/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
		<item>
		<title>Validating EPUB 3 experiments</title>
		<link>http://blog.threepress.org/2011/06/13/validating-epub-3-today/</link>
		<comments>http://blog.threepress.org/2011/06/13/validating-epub-3-today/#comments</comments>
		<pubDate>Mon, 13 Jun 2011 13:30:45 +0000</pubDate>
		<dc:creator>Keith Fahlgren</dc:creator>
				<category><![CDATA[epub]]></category>
		<category><![CDATA[epub3]]></category>
		<category><![CDATA[geek]]></category>

		<guid isPermaLink="false">http://blog.threepress.org/?p=2042</guid>
		<description><![CDATA[EPUB 3 is tricky to experiment with today. Like any brand-new specification, there aren’t many of the resources we often take for granted, from books to software to validation tools. However, if you’re already comfortable getting your hands dirty you can get meaningful validation for your EPUB 3 documents now. In the future, we’ll probably [...]]]></description>
			<content:encoded><![CDATA[<p><a href="http://www.idpf.org/epub/30/spec/epub30-overview.html">EPUB 3</a> is tricky to experiment with today. Like any brand-new specification, there aren’t many of the resources we often take for granted, from books to software to validation tools. However, if you’re already comfortable getting your hands dirty you can get meaningful validation for your EPUB 3 documents now. In the future, we’ll probably have a dedicated EPUB 3 validation tool (modeled somewhat on <a href="http://code.google.com/p/epubcheck/">epubcheck</a>, although with quite a few changes, I hope), but I’d like to start working today. This post outlines how.</p>
<p><em>Note:</em> I’m going to give examples using a number of bare-metal tools available on Mac OS X. These are probably portable to Linux and even Windows if you were motivated, but I’m not going to explain how to install them or set them up (here or in the comments). <a href="http://google.com">Google is your friend</a>.</p>
<p><span id="more-2042"></span></p>
<p>To get started, download <a href="http://idpf.org/epub/30/schema/epub30-schemas.zip">all of the EPUB 3 schemas</a> (I put them in an <code>epub30-schemas/</code> directory), install the absolute latest version of the RELAX NG validator <a href="http://jing-trang.googlecode.com/files/jing-20091111.zip">Jing</a> (<code>jing-20091111/</code> for me), download the Schematron tools at <a href="http://www.schematron.com/implementation.html">iso-schematron-xslt1.zip is for XSLT1 processors</a> (<code>iso-schematron</code> for me), and make sure you’ve got access to both <a href="http://xmlsoft.org/XSLT/xsltproc2.html">xsltproc</a> and <code>java</code>. Finally, save this as <code>svrl_as_text.xsl</code>:</p>
<pre class="brush: xml;">
&lt;?xml version=&quot;1.0&quot;?&gt;
&lt;xsl:stylesheet xmlns:xsl=&quot;http://www.w3.org/1999/XSL/Transform&quot;
            xmlns:svrl=&quot;http://purl.oclc.org/dsdl/svrl&quot;
            version=&quot;1.0&quot;&gt;
  &lt;xsl:output method=&quot;text&quot;/&gt;

  &lt;xsl:template match=&quot;*|node()&quot;&gt;
    &lt;xsl:apply-templates/&gt;
  &lt;/xsl:template&gt;
  &lt;xsl:template match=&quot;svrl:failed-assert|
                       svrl:successful-report&quot;&gt;
    &lt;xsl:text&gt;FAILURE: &lt;/xsl:text&gt;
    &lt;xsl:value-of select=&quot;local-name(.)&quot;/&gt;
    &lt;xsl:text&gt;: &lt;/xsl:text&gt;
    &lt;xsl:value-of select=&quot;normalize-space(svrl:text/text())&quot;/&gt;
    &lt;xsl:text&gt;&amp;#10;&lt;/xsl:text&gt;
  &lt;/xsl:template&gt;
&lt;/xsl:stylesheet&gt;
</pre>
<h3>Layout of the EPUB 3 schemas</h3>
<p>All of the schemas for EPUB 3 are available as <a href="http://relaxng.org/">RELAX NG</a> and sometimes <a href="www.schematron.com">Schematron</a>. Each one has specific strengths, so we use both schemas whenever possible to get a complete list of all the validation issues. The <a href="http://idpf.org/epub/30/schema/">EPUB 3 schemas</a> are broken into separate files for each type of document inside an EPUB 3. You should notice that there is a RELAX NG Compact <code>.rnc</code> file for each type:</p>
<pre>
epub30-schemas/epub-nav-30.rnc        # EPUB Navigation Document
epub30-schemas/epub-svg-30.rnc        # SVG Content Documents
epub30-schemas/epub-xhtml-30.rnc      # XHTML Content Documents
epub30-schemas/media-overlay-30.rnc   # Media Overlay Documents
epub30-schemas/ocf-container-30.rnc   # META-INF/container.xml
epub30-schemas/ocf-encryption-30.rnc  # META-INF/encryption.xml
epub30-schemas/ocf-signatures-30.rnc  # META-INF/signatures.xml
epub30-schemas/package-30.rnc         # Package Documents
</pre>
<p>Unsurprisingly, you use a RELAX NG validator with <code>epub30-schemas/media-overlay-30.rnc</code> to validate a Media Overlay document.</p>
<p>A few of these documents also have a Schematron schema with the same prefix but ending with <code>.sch</code>, which is used to express other requirements that aren’t possible in RELAX NG:</p>
<pre>
epub30-schemas/epub-nav-30.sch
epub30-schemas/epub-svg-30.sch
epub30-schemas/epub-xhtml-30.sch
epub30-schemas/media-overlay-30.sch
epub30-schemas/package-30.sch
</pre>
<p>There are some standalone Schematron validators, but we’re actually going to roll our own tool for more human-readable output.</p>
<p>There’s a third file extension too, <code>.nvdl</code>, which is short for <a href="http://nvdl.org/">Namespace-based Validation Dispatching Language</a>. These files are supposed to wrap these two schemas together for unified validation tools, but there isn’t good software support for NVDL today. Ignore the <code>.nvdl</code> files for now.</p>
<h3>What to validate</h3>
<p>I’m currently interested in the <a href="http://idpf.org/epub/30/spec/epub30-contentdocs.html#sec-xhtml-nav">EPUB Navigation Document</a>, a reformulation of EPUB’s NCX document as XHTML, so these are the examples we’ll use. However, this approach should work for any of the other document types if you go through the same setup. </p>
<p>Here is a valid, if short, EPUB Navigation Document:</p>
<pre class="brush: xml;">
&lt;?xml version=&quot;1.0&quot; encoding=&quot;UTF-8&quot;?&gt;
&lt;html xmlns=&quot;http://www.w3.org/1999/xhtml&quot;
      xmlns:epub=&quot;http://www.idpf.org/2007/ops&quot;
      profile=&quot;http://www.idpf.org/epub/30/profile/content/&quot;&gt;
  &lt;head&gt;
    &lt;title&gt;EPUB Navigation Document Example (Good)&lt;/title&gt;
    &lt;meta http-equiv=&quot;content-type&quot; content=&quot;text/html; charset=utf-8&quot;/&gt;
  &lt;/head&gt;
  &lt;body&gt;
    &lt;section class=&quot;frontmatter TableOfContents&quot;&gt;
      &lt;header&gt;
        &lt;h1&gt;Contents&lt;/h1&gt;
      &lt;/header&gt;
      &lt;nav epub:type=&quot;toc&quot; id=&quot;toc&quot;&gt;
        &lt;ol&gt;
          &lt;li class=&quot;toc-prelin&quot; id=&quot;toc-prelim&quot;&gt;
            &lt;a href=&quot;prelims.html&quot;&gt;Introduction&lt;/a&gt;
          &lt;/li&gt;
          &lt;li class=&quot;toc-ch01&quot; id=&quot;toc-ch01&quot;&gt;
            &lt;a href=&quot;ch01.html&quot;&gt;Chapter 1&lt;/a&gt;
          &lt;/li&gt;
          &lt;li&gt;
            &lt;a href=&quot;copyright.html&quot;&gt;Copyright Page&lt;/a&gt;
          &lt;/li&gt;
        &lt;/ol&gt;
      &lt;/nav&gt;
      &lt;nav epub:type=&quot;landmarks&quot; id=&quot;guide&quot;&gt;
        &lt;h2&gt;Guide&lt;/h2&gt;
        &lt;ol&gt;
          &lt;li&gt;
            &lt;a epub:type=&quot;toc&quot; href=&quot;#toc&quot;&gt;Table of Contents&lt;/a&gt;
          &lt;/li&gt;
          &lt;li&gt;
            &lt;a epub:type=&quot;bodymatter&quot; href=&quot;chapter_001.xhtml&quot;&gt;Begin Reading&lt;/a&gt;
          &lt;/li&gt;
          &lt;li&gt;
            &lt;a epub:type=&quot;copyright-page&quot; href=&quot;copyright.xhtml&quot;&gt;Copyright Page&lt;/a&gt;
          &lt;/li&gt;
        &lt;/ol&gt;
      &lt;/nav&gt;
    &lt;/section&gt;
  &lt;/body&gt;
&lt;/html&gt;
</pre>
<p>And here is one with a few errors that should be reported as invalid:</p>
<pre class="brush: xml;">

&lt;?xml version=&quot;1.0&quot; encoding=&quot;UTF-8&quot;?&gt;
&lt;html xmlns=&quot;http://www.w3.org/1999/xhtml&quot;
      xmlns:epub=&quot;http://www.idpf.org/2007/ops&quot;
      profile=&quot;http://www.idpf.org/epub/30/profile/content/&quot;&gt;
  &lt;head&gt;
    &lt;title&gt;EPUB Navigation Document Example (Bad)&lt;/title&gt;
    &lt;meta http-equiv=&quot;content-type&quot; content=&quot;text/html; charset=utf-8&quot;/&gt;
  &lt;/head&gt;
  &lt;body&gt;
    &lt;section class=&quot;frontmatter TableOfContents&quot;&gt;
      &lt;header&gt;
        &lt;h1&gt;Contents&lt;/h1&gt;
      &lt;/header&gt;
      &lt;nav&gt;
        &lt;!-- this is omitted, which is invalid: epub:type=&quot;toc&quot; id=&quot;toc&quot; --&gt;
        &lt;ol&gt;
          &lt;li class=&quot;toc-prelin&quot; id=&quot;toc-prelim&quot;&gt;
            &lt;a href=&quot;prelims.html&quot;&gt;Introduction&lt;/a&gt;
          &lt;/li&gt;
          &lt;li class=&quot;toc-ch01&quot; id=&quot;toc-ch01&quot;&gt;
            &lt;a href=&quot;ch01.html&quot;&gt;Chapter 1&lt;/a&gt;
            &lt;!-- This is invalid --&gt;
            &lt;span/&gt;
          &lt;/li&gt;
          &lt;li&gt;
            &lt;a href=&quot;copyright.html&quot;&gt;Copyright Page&lt;/a&gt;
          &lt;/li&gt;
        &lt;/ol&gt;
      &lt;/nav&gt;
      &lt;nav epub:type=&quot;landmarks&quot; id=&quot;guide&quot;&gt;
        &lt;h2&gt;Guide&lt;/h2&gt;
        &lt;ol&gt;
          &lt;li&gt;
            &lt;a epub:type=&quot;toc&quot; href=&quot;#toc&quot;&gt;Table of Contents&lt;/a&gt;
          &lt;/li&gt;
          &lt;li&gt;
            &lt;a epub:type=&quot;bodymatter&quot; href=&quot;chapter_001.xhtml&quot;&gt;Begin Reading&lt;/a&gt;
          &lt;/li&gt;
          &lt;li&gt;
            &lt;a epub:type=&quot;copyright-page&quot; href=&quot;copyright.xhtml&quot;&gt;Copyright Page&lt;/a&gt;
          &lt;/li&gt;
        &lt;/ol&gt;
      &lt;/nav&gt;
    &lt;/section&gt;
  &lt;/body&gt;
&lt;/html&gt;
</pre>
<h3>RELAX NG validation with Jing</h3>
<p>Once you’ve got <code>jing</code> setup, it’s pretty straightforward to validate our files (above) against the appropriate <code>.rnc</code>. We’ll be using the  <code>epub30-schemas/epub-nav-30.rnc</code> schema.</p>
<p>When you run <code>jing</code> against a file and it passes, you get no output (good) and an exit code of <code>0</code>. I’m calling <code>jing</code> as <code>java -jar jing-20091111/bin/jing.jar</code>, passing the <code>-c</code> flag to tell it to expect a Compact version of RELAX NG, and then the schema filename followed by the filename of the document to validate:</p>
<pre>$ java -jar jing-20091111/bin/jing.jar -c epub30-schemas/epub-nav-30.rnc good.nav.html
$ echo $? # What was the exit code?
0</pre>
<p>Unlike earlier versions of <code>jing</code>, the latest versions have much clearer error reports on invalid documents (we also saw this improvement in <a href="http://blog.threepress.org/2011/03/24/epubcheck-1-2-released/">epubcheck 1.2</a> thanks to George Bina from <a href="http://www.oxygenxml.com/">oXygen</a>):</p>
<pre>$ java -jar jing-20091111/bin/jing.jar -c epub30-schemas/epub-nav-30.rnc bad.nav.html
bad.nav.html:21:20: error: element "span" not allowed here; expected the element end-tag or element "ol"
</pre>
<p>&#8230;and the exit code is not <code>0</code>, just as expected:</p>
<pre>$ echo $?
1</pre>
<p>We can take apart that first bit out output, <code>bad.nav.html:21:20</code>, to know which file had the error (we could run it on many at once) and also the line number (<code>21</code>) and character on that line (<code>20</code>). Line 21 has just what we would expect given the error message (a <code>span</code> instead of another <code>ol</code> or the end of this one), but for other errors it can be quite illuminating:</p>
<pre>$ sed -n -e 21p bad.nav.html
            &lt;span/&gt;
</pre>
<p><em>Note:</em> For really large documents, you may get an <code>java.lang.OutOfMemoryError</code> or other exception. Find out how to give <code>jing</code> more “heap space”.</p>
<h3>Schematron validation with XSLT</h3>
<p>Validating the Schematron schemas is a little more involved, but it catches some validation errors than <code>jing</code> and RELAX NG just cannot find. First we turn the <code>.sch</code> file into a re-usable XSLT stylesheet that produces Schematron Validation Report Language (SVRL). We can then run that stylesheet on any document of that type inside an EPUB 3 file to produce SVRL, which we then transform into something human-readable.</p>
<p>First we create our validation stylesheet, <code>epub-nav-30.sch.xsl</code>, from the <code>epub30-schemas/epub-nav-30.sch</code> Schematron schema:</p>
<pre>$ xsltproc -o epub-nav-30.sch.xsl iso-schematron/iso_svrl_for_xslt1.xsl epub30-schemas/epub-nav-30.sch</pre>
<p>Now we can use <code>epub-nav-30.sch.xsl</code> on any EPUB Navigation Document:</p>
<pre>$ xsltproc epub-nav-30.sch.xsl bad.nav.html</pre>
<pre class="brush: xml;">
&lt;?xml version=&quot;1.0&quot; standalone=&quot;yes&quot;?&gt;
&lt;svrl:schematron-output xmlns:svrl=&quot;http://purl.oclc.org/dsdl/svrl&quot; xmlns:xs=&quot;http://www.w3.org/2001/XMLSchema&quot;
xmlns:schold=&quot;http://www.ascc.net/xml/schematron&quot; xmlns:sch=&quot;http://www.ascc.net/xml/schematron&quot;
xmlns:iso=&quot;http://purl.oclc.org/dsdl/schematron&quot; xmlns:html=&quot;http://www.w3.org/1999/xhtml&quot; xmlns:epub=&quot;http://www.idpf.org/2007/ops&quot; title=&quot;&quot; schemaVersion=&quot;&quot;&gt;
  &lt;!--   
		   
		   
		 --&gt;
  &lt;svrl:ns-prefix-in-attribute-values uri=&quot;http://www.w3.org/1999/xhtml&quot; prefix=&quot;html&quot;/&gt;
  &lt;svrl:ns-prefix-in-attribute-values uri=&quot;http://www.idpf.org/2007/ops&quot; prefix=&quot;epub&quot;/&gt;
  &lt;svrl:active-pattern id=&quot;nav-ocurrence&quot; name=&quot;nav-ocurrence&quot;/&gt;
  &lt;svrl:fired-rule context=&quot;html:body&quot;/&gt;
   ... many more lines ...
</pre>
<p>&#8230;but we rarely want to read the SVRL it outputs directly (although sometimes it is worth it for the extra detail it contains), so we need to send it through another stylesheet (<code>svrl_as_text.xsl</code> from above) to get a human-readable output:</p>
<pre>$ xsltproc epub-nav-30.sch.xsl bad.nav.html | xsltproc svrl_as_text.xsl -
FAILURE: failed-assert: Exactly one 'toc' nav element must be present
FAILURE: failed-assert: Spans within nav elements must contain text
FAILURE: failed-assert: nav elements other than 'toc', 'page-list' and 'landmarks' must contain a heading as the first child
</pre>
<p>These are completely new issues that <code>jing</code> could not catch. Note that the issue about the <code>span</code> is actually distinct from the one above, which said it was in the wrong <em>place</em>, whereas this says that it has the wrong content (none at all, in fact).</p>
<p>Unlike <code>jing</code>, we don’t get meaningful exit codes. Although that is not too hard to add, it’s slight tricky to get <strong>all</strong> of the errors and exit codes rather than just exiting on the first one, which can make you think your document is less invalid than it really is. We still get no output for valid documents:</p>
<pre>$ xsltproc epub-nav-30.sch.xsl good.nav.html | xsltproc svrl_as_text.xsl -
# no output</pre>
<hr />
<p>I’m certain to have made lots of mistakes in the examples above. If you spot some, please let me know in the comments and I’ll correct the post.</p>
]]></content:encoded>
			<wfw:commentRss>http://blog.threepress.org/2011/06/13/validating-epub-3-today/feed/</wfw:commentRss>
		<slash:comments>5</slash:comments>
		</item>
		<item>
		<title>Cost-effective Development of Enhanced Content with EPUB3 (Digital Book World 2011)</title>
		<link>http://blog.threepress.org/2011/01/31/cost-effective-development-of-enhanced-content-with-epub3-digital-book-world-2011/</link>
		<comments>http://blog.threepress.org/2011/01/31/cost-effective-development-of-enhanced-content-with-epub3-digital-book-world-2011/#comments</comments>
		<pubDate>Mon, 31 Jan 2011 13:59:44 +0000</pubDate>
		<dc:creator>Liza Daly</dc:creator>
				<category><![CDATA[conferences]]></category>
		<category><![CDATA[css]]></category>
		<category><![CDATA[epub]]></category>
		<category><![CDATA[geek]]></category>
		<category><![CDATA[html5]]></category>
		<category><![CDATA[ibooks]]></category>
		<category><![CDATA[interactivity]]></category>
		<category><![CDATA[talks]]></category>
		<category><![CDATA[video]]></category>

		<guid isPermaLink="false">http://blog.threepress.org/?p=1789</guid>
		<description><![CDATA[I presented at Digital Book World 2011 about using EPUB3 to produce multimedia and interactive ebooks that will be compatible with multiple devices and software ereaders.
Anyone who&#8217;s ever been to a digital publishing conference knows that there is always a bewildering array of products that create and display enhanced content: ebooks that contain video, audio, [...]]]></description>
			<content:encoded><![CDATA[<p>I presented at <a href="http://dbw2011.digitalbookworld.com/cost-effective/">Digital Book World 2011</a> about using EPUB3 to produce multimedia and interactive ebooks that will be compatible with multiple devices and software ereaders.</p>
<p>Anyone who&#8217;s ever been to a digital publishing conference knows that there is always a bewildering array of products that create and display enhanced content: ebooks that contain video, audio, animation, or other forms of interactivity.  Generally each new platform requires an entirely different way of preparing the content and all the multimedia assets. While the production of static ebooks has become relatively standardized (using EPUB2), publishers are still struggling with how to produce more digital-native products without tremendous expense and constant re-tooling.</p>
<p>I&#8217;m optimistic that EPUB3 will provide significant headache-reduction in this area. While creating high-quality static, pure-text ebooks still has challenges, things are a lot better today than even a year ago.  If we&#8217;re to see similar consolidation in the enhanced ebook space in the same timeframe, publishers are going to have to be firm that they will only (or at least primarily) produce standards-based multimedia books.</p>
<h3>Slides from DBW</h3>
<div style="margin:auto; width:425px" id="__ss_6754013"><strong style="display:block;margin:12px 0 4px"><a href="http://www.slideshare.net/lizadaly/costeffective-enhanced-ebooks-with-epub3" title="Cost-effective enhanced ebooks with EPUB3">Cost-effective enhanced ebooks with EPUB3</a></strong><object id="__sse6754013" width="425" height="355"><param name="movie" value="http://static.slidesharecdn.com/swf/ssplayer2.swf?doc=dbw-2011-liza-daly-110130145804-phpapp02&#038;stripped_title=costeffective-enhanced-ebooks-with-epub3&#038;userName=lizadaly" /><param name="allowFullScreen" value="true"/><param name="allowScriptAccess" value="always"/><embed name="__sse6754013" src="http://static.slidesharecdn.com/swf/ssplayer2.swf?doc=dbw-2011-liza-daly-110130145804-phpapp02&#038;stripped_title=costeffective-enhanced-ebooks-with-epub3&#038;userName=lizadaly" type="application/x-shockwave-flash" allowscriptaccess="always" allowfullscreen="true" width="425" height="355"></embed></object>
<div style="padding:5px 0 12px">View more <a href="http://www.slideshare.net/">presentations</a> from <a href="http://www.slideshare.net/lizadaly">lizadaly</a>.</div>
</div>
<h3>EPUB3 interactivity demo in iBooks</h3>
<p>The talk includes a video demo.  I had created an EPUB document several months ago for a research project, using <a href="http://www.archive.org/details/abroadcranethoma00craniala">Abroad</a> by Thomas Crane as source material (edition from the <a href="http://archive.org/">Internet Archive</a>).   I wanted to emulate the accelerometer-driven animation of the <a href="http://gizmodo.com/5515612/the-cleverest-ipad-book-yet">Alice for iPad</a> book using only the tools available in EPUB3.</p>
<p>Since the source was a heavily-illustrated children&#8217;s book, EPUB&#8217;s reflow capability was not really an asset. This quality made the book perfect for use in <a href="http://blog.threepress.org/2011/01/17/understanding-apples-fixed-layout-epubs/">Apple&#8217;s fixed-layout mode</a>.  The video below shows the book running in iBooks on an iPad: </p>
<p><embed style="margin:auto; text-align:center; display:block;" src="http://blip.tv/play/AYKgiGkA" type="application/x-shockwave-flash" width="640" height="454" allowscriptaccess="always" allowfullscreen="true"></embed><h3>Accelerometer</h3>
<p>In the first example, I use the accelerometer interface in JavaScript (<a href="http://www.mobilexweb.com/blog/safari-ios-accelerometer-websockets-html5">some sample code</a>), to cause the ship to &#8220;sail&#8221; back and forth as the user tilts the device.</p>
<h3>Animation</h3>
<p>In the second example, if the user touches any of the birds on the title page, they fly away. I modified the <a href="https://github.com/weepy/jquery.path">jQuery Path</a> library to use CSS3 transforms to efficiently animate along a curve. JavaScript performance in iBooks appears to be somewhat worse than Mobile Safari; optimizing using CSS3 rather than DOM position updates is recommended.</p>
<h3>Canvas, Processing.js, HTML5 audio</h3>
<p>I&#8217;m a big fan of the <a href="http://processingjs.org/">Processing</a> visual programming language.  In the last example, the train appears to give off puffs of steam; each time the steam comes out of the train the puffs are in slightly different positions.</p>
<p>I embedded Processing.js code (which is itself then interpreted by JavaScript) and rendered the puffs to a transparent canvas.  The puffs appear in a slightly random position,  fade out as they reach the top of the page and then spawn anew.  </p>
<p>Finally, there&#8217;s also an event bound to the invisible canvas: tapping on it will fire an HTML5 audio (a sample of a train).</p>
<p><em>(At this time we&#8217;re not able to share the demo EPUB file itself.)</em></p>
]]></content:encoded>
			<wfw:commentRss>http://blog.threepress.org/2011/01/31/cost-effective-development-of-enhanced-content-with-epub3-digital-book-world-2011/feed/</wfw:commentRss>
		<slash:comments>5</slash:comments>
		</item>
		<item>
		<title>Understanding Apple&#8217;s fixed-layout EPUBs</title>
		<link>http://blog.threepress.org/2011/01/17/understanding-apples-fixed-layout-epubs/</link>
		<comments>http://blog.threepress.org/2011/01/17/understanding-apples-fixed-layout-epubs/#comments</comments>
		<pubDate>Mon, 17 Jan 2011 15:29:20 +0000</pubDate>
		<dc:creator>Liza Daly</dc:creator>
				<category><![CDATA[css]]></category>
		<category><![CDATA[ebooks]]></category>
		<category><![CDATA[epub]]></category>
		<category><![CDATA[geek]]></category>
		<category><![CDATA[html5]]></category>
		<category><![CDATA[interactivity]]></category>
		<category><![CDATA[ipad]]></category>

		<guid isPermaLink="false">http://blog.threepress.org/?p=1765</guid>
		<description><![CDATA[iBooks now supports an extension to EPUB that allows publishers to create books with precise layout using CSS. This is Apple&#8217;s own extension, not part of the EPUB specification itself (and not one that they suggested be included in EPUB3).
The goal of this post is to simply document the extension and show how to create [...]]]></description>
			<content:encoded><![CDATA[<p>iBooks now supports an extension to EPUB that allows publishers to create books with precise layout using CSS. This is Apple&#8217;s own extension, not part of the EPUB specification itself (and not one that they suggested be included in EPUB3).</p>
<p>The goal of this post is to simply document the extension and show how to create new works with it. I&#8217;m not going to debate whether it&#8217;s a good thing for the ecosystem here.</p>
<h2>Install Phone Disk</h2>
<p>Anyone working extensively with iBooks EPUB development should first grab a copy of the invaluable <a href="http://www.macroplant.com/phonedisk/">Phone Disk</a>.  This allows Mac and Windows computers to browse most of the iOS device filesystem as a normal drive, including opening and inspecting EPUB books.</p>
<h2>Download a fixed-layout EPUB sample from the iBookstore</h2>
<p>iBooks samples do not have DRM and so can be opened and read normally. A good bet is to download one of the &#8220;Children&#8217;s Picture Books&#8221;; these tend to be fixed-layout books.</p>
<h2>Find the display-options file</h2>
<p>The key component of the extension is the addition of the file <code>META-INF/com.apple.ibooks.display-options.xml</code>. This file tells iBooks that the book is the fixed-layout type, and typically looks something like this:</p>
<pre class="brush: xml;">
&lt;?xml version=&quot;1.0&quot; encoding=&quot;UTF-8&quot;?&gt;
&lt;display_options&gt;
    &lt;platform name=&quot;*&quot;&gt;
        &lt;option name=&quot;fixed-layout&quot;&gt;true&lt;/option&gt;
    &lt;/platform&gt;
&lt;/display_options&gt;
</pre>
<p>There are a number of options here which are detailed in the iBookstore Asset Guide (v4.5), including how to define two-page spreads.</p>
<p>The first thing I tried with one of the samples was to validate it with the latest <a href="http://code.google.com/p/epubcheck/">epubcheck 1.1</a>:</p>
<blockquote><p>Epubcheck Version 1.1<br />
WARNING: /Users/liza/foo.epub: item (iTunesMetadata.plist) exists in the zip file, but is not declared in the OPF file<br />
WARNING: /Users/liza/foo.epub: item (iTunesArtwork) exists in the zip file, but is not declared in the OPF file
</p></blockquote>
<p>These are just warnings; the fixed-layout book is valid.  You can try opening them in other EPUB readers, with varying success depending on how wild the book designer got with the fixed-positioning.</p>
<h2>Inspect the OPF and NCX</h2>
<p>One immediate surprise to iBooks developers is that you&#8217;re likely to find an embedded font (now supported in any iBooks EPUB). Otherwise there&#8217;s nothing added to the OPF.</p>
<p>The NCX examples I found did not include all of the XHTML pages; I&#8217;m not sure whether that&#8217;s just a function of the book being a sample.</p>
<h2>Structure of a fixed-layout book</h2>
<p>In a typical EPUB, each chapter or major division of content is a single XHTML file. In the fixed-layout model, each XHTML file corresponds to a single physical page. So while it&#8217;s typical to name most EPUB XHTML files like <code>chapter01.html</code>, <code>chapter02.html</code>, in the fixed-layout book you&#8217;re apt to see a layout like:</p>
<pre>
cover.xhtml	font		package.opf	page001.xhtml	page003.xhtml	toc.ncx
css		images		page000.xhtml	page002.xhtml	page004.xhtml
</pre>
<h2>XHTML content</h2>
<p>The one unusual element in the fixed-layout content will be this HTML, which is required:</p>
<pre class="brush: xml;">
&lt;meta name=&quot;viewport&quot; content=&quot;width=1000, height=1000&quot;&gt;&lt;/meta&gt;
</pre>
<p>The specific width/height is per-book and based on the desired dimensions of the page. iBooks uses this information to scale the screen size appropriately (more on this later).</p>
<p>Otherwise the XHTML should look relatively normal (other than being very short). In fact the XHTML will be exceptionally readable since these books are by necessity all hand-coded at the moment.</p>
<h2>CSS</h2>
<p>Here&#8217;s where things get interesting:</p>
<p>The <code>body</code> element must be defined with an absolute width/height that matches the <code>viewport</code> above:</p>
<pre class="brush: css;">
body {
	width: 1000px;
	height: 1000px;
}
</pre>
<p>Images and text will often be absolutely-positioned. <code>z-index</code> and other advanced positioning techniques are also supported.  Font sizes are specified in <em>pixels</em>, not <em>ems</em> (users can zoom fixed-layout books, but the text will not reflow). Background colors are useful in this model as the XHTML content is full-bleed and does not usually have the goofy fake book margin.</p>
<p>Since this is all standard CSS 2.1 (or CSS3), these books don&#8217;t technically require a specialized reading system; any one based on a modern browser, like the mobile version of <a href="http://ibisreader.com/">Ibis Reader</a>, could potentially consume these books if the reading system could scale the pages appropriately.</p>
<h2>Interactivity</h2>
<p>It&#8217;s been noted that my original <a href="http://blog.threepress.org/2010/06/24/javascript-and-interactivity-in-ibooks/">JavaScript in EPUB</a> example no longer works in more recent versions of iBooks.  This had nothing to do with the JavaScript parts themselves; instead the problem was that Apple began squashing the positioning information needed to align the popups.</p>
<p>In recent work for publishers I&#8217;ve found ways to get around those limitations, but they&#8217;ve been quite awkward and difficult to author. Would the &#8220;freedoms&#8221; of positioning in the fixed-layout books allow the original sample to work again?</p>
<p>Yes!</p>
<p>I took my original file and made only three changes:</p>
<ol>
<li>I added the <code>com.apple.ibooks.display-options.xml</code> file just as shown above.</li>
<li>I added the <code>viewport</code> directive to the XHTML file and set it (arbitrarily to 600 pixels wide, 800 pixels tall).</li>
<li>I modified the CSS <code>body</code> directive to match the viewport.</li>
</ol>
<p>The result:</p>
<p><a href="http://blog.threepress.org/wp-content/uploads/2011/01/javascript-in-ibooks-fixed-positioning.png"><img src="http://blog.threepress.org/wp-content/uploads/2011/01/javascript-in-ibooks-fixed-positioning-225x300.png" alt="" title="javascript-in-ibooks-fixed-positioning" width="225" height="300" class="aligncenter size-medium wp-image-1767" /></a></p>
<p><a href="http://3press-blog.s3.amazonaws.com/javascript-in-epub-fixed.epub">Download the example EPUB</a> (<a href="http://creativecommons.org/licenses/by-nc-sa/3.0/">Creative Commons Attribution-Noncommercial-Share Alike 3.0</a>)</p>
<p>Obviously the layout could use some work; there&#8217;s no longer any default margin added by the ereader, so the text bleeds out.  Also my 600&#215;800 dimensions don&#8217;t exactly match the iBooks aspect ratio, so there&#8217;s more fake book border.  But you can see how this could be improved.</p>
<p><strong>Note that the vast majority of EPUB books should <em>not</em> be formatted this way.</strong>  This isn&#8217;t a one-way ticket to CSS Town.  <em>If the text on a particular XHTML page overflows the bottom of the single page, it will get cut off.</em>  You cannot mix fixed-layout and reflowable pages in the same EPUB file.</p>
]]></content:encoded>
			<wfw:commentRss>http://blog.threepress.org/2011/01/17/understanding-apples-fixed-layout-epubs/feed/</wfw:commentRss>
		<slash:comments>23</slash:comments>
		</item>
		<item>
		<title>How to embed fonts in ePub files</title>
		<link>http://blog.threepress.org/2009/09/16/how-to-embed-fonts-in-epub-files/</link>
		<comments>http://blog.threepress.org/2009/09/16/how-to-embed-fonts-in-epub-files/#comments</comments>
		<pubDate>Wed, 16 Sep 2009 20:06:42 +0000</pubDate>
		<dc:creator>Liza Daly</dc:creator>
				<category><![CDATA[book design]]></category>
		<category><![CDATA[epub]]></category>
		<category><![CDATA[geek]]></category>

		<guid isPermaLink="false">http://blog.threepress.org/?p=607</guid>
		<description><![CDATA[(You may be interested in the earlier article, When to embed fonts in ePub files.)
Font selection
Font formats and licensing are complicated. The ePub specification recommends that book designers and reading system implementers use OpenType fonts when possible (although TrueType fonts remain more common). If your font ends in a .otf extension, it&#8217;s an OpenType font. [...]]]></description>
			<content:encoded><![CDATA[<p>(You may be interested in the earlier article, <a href="http://blog.threepress.org/2009/09/16/when-to-embed-fonts-in-epub-files/">When to embed fonts in ePub files</a>.)</p>
<h2>Font selection</h2>
<p>Font formats and licensing are complicated. The ePub specification recommends that book designers and reading system implementers use <a href="http://en.wikipedia.org/wiki/OpenType">OpenType</a> fonts when possible (although <a href="http://en.wikipedia.org/wiki/TrueType">TrueType</a> fonts remain more common). If your font ends in a <tt>.otf</tt> extension, it&#8217;s an OpenType font.  I&#8217;ll use OpenType in my discussion here.</p>
<h3>Licensing</h3>
<p>Font licenses may allow you to use the font in printed collateral or even digital documents, but may not allow you to embed that font for distribution elsewhere. It&#8217;s unclear whether specific foundries consider bundling a font with an ebook to be violating their license.  Theoretically, nothing stops the end-user from unzipping the .epub file and taking out the font, so bundling it with an epub could be considered a form of distribution.</p>
<p>One method to allow font inclusion without violating any license is to employ font obfuscation.  Adobe has released some open-source code in <a href="http://code.google.com/p/epub-tools/">epub-tools</a> to enable this, and provided <a href="http://blogs.adobe.com/digitaleditions/2009/05/font_mangling_code_available_f.html">detailed documentation</a> for software developers who want to implement the algorithm.  I&#8217;m not aware of any readers besides ADE that can read fonts obfuscated in this manner, though.</p>
<h4>Fonts with open licenses</h4>
<p>My preferred solution for bundling fonts is to dodge the entire licensing issue altogether by using an open license.  The <a href="http://www.gnome.org/fonts/">Bitstream Vera</a> fonts have a generous license and good Unicode support, but don&#8217;t include all possible serif/italic/bold combinations.  A later variant called <a href="http://en.wikipedia.org/wiki/DejaVu_fonts">DejaVu</a> improves on this by including more faces and even better Unicode support.</p>
<p>My favorite fonts in terms of good Unicode support combined with an open license are the <a href="http://en.wikipedia.org/wiki/Liberation_fonts">Liberation</a> series.  These are workhorse fonts designed to resemble the basic Microsoft set of Arial, Times and Courier.  Nothing fancy, but they&#8217;re screen-readable and contain a wide range of characters.</p>
<h2>How to embed a font</h2>
<p>If you&#8217;re not afraid of specs, I recommend reviewing the <a href="http://www.w3.org/TR/1998/REC-CSS2-19980512/fonts.html#font-selection">CSS2 @font-face rule</a>.  But here&#8217;s the step-by-step:</p>
<h3>0. Convert the font to OpenType</h3>
<p>This is step 0 because it&#8217;s not strictly required, and you may already be starting from an OpenType font. I usually convert TTF fonts to OTF with <a href="http://fontforge.sourceforge.net/">FontForge</a>. FontForge is not the friendliest software but it will do the job.  Commercial font software will be much easier to use but tends to be expensive.  Or you can just skip this step.</p>
<h3>1. Add the font to the OPF package</h3>
<p><em>Every file in your epub must be declared in the OPF manifest</em>. This includes fonts.  Put the font in the same place as your OPF file (usually a folder called <tt>OEBPS</tt>) and add it to the manifest.  For example:</p>
<blockquote><p>
<code>&lt;item id="epub.embedded.font" href="MyFont.otf" media-type="font/opentype"/&gt;</code>
</p></blockquote>
<h3>1.a Repeat for all combinations of faces</h3>
<p>You will probably want to add additional packages to support all combinations of bold, italics, serif and sans-serif (as users may be able to switch serif settings in their reader).</p>
<h3>2. Create the CSS @font-face rules</h3>
<p>This is standard CSS from here on out; nothing ePub specific:</p>
<h4>Declare the font itself</h4>
<p>This tells CSS that you will be using a particular font in the document.  It doesn&#8217;t say where it will be used, so just including this directive will have no effect:</p>
<pre class="brush: css;">@font-face {
  font-family : MyFont;
  font-weight : normal;
  font-style: normal;
  src : url(MyFont.otf);
}</pre>
<p>Now we need to tell the CSS where this font should be used.  To set it as the default font for the entire document, apply it to the &lt;body&gt; element:</p>
<pre class="brush: css;">body {
  font-family: &quot;MyFont&quot;, serif;
}</pre>
<p>This should be the last rule in your CSS.</p>
<p>Note that the generic &#8220;serif&#8221; declaration follows our declared font. I don&#8217;t recommend declaring any other fallback fonts besides just serif or sans-serif.</p>
<p>If you included italic or bold variants separately, add them as:</p>
<pre class="brush: css;">@font-face {
  font-family : MyFontBold;
  font-weight : bold;
  font-style: normal;
  src : url(MyFontBold.otf);
}

@font-face {
  font-family : MyFontItalic;
  font-weight : normal;
  font-style: italic;
  src : url(MyFontItalic.otf);
}

strong, b {
  font-family: &quot;MyFontBold&quot;, serif;
}

em, i {
  font-family: &quot;MyFontItalic&quot;, serif;
}</pre>
<p>You may need to tweak the font assignments for particular elements. For example, &lt;blockquote&gt; is typically rendered in italics; you&#8217;ll need to assign that to the italic variant as well. </p>
<h2>3. Validate your ePub</h2>
<p>This has nothing to do with fonts, but you should be <a href="http://threepress.org/document/epub-validate">validating any ePub</a> you generate.</p>
<h2>4. Test it out</h2>
<p>The earlier <a href="http://blog.threepress.org/2009/09/16/when-to-embed-fonts-in-epub-files/">font embedding article</a> contains a list of readers which support embedded fonts. If possible I recommend testing both on Adobe Digital Editions and a compatible eink reader.</p>
<p>(Many thanks to <a href="http://twitter.com/abdelazer">Keith Fahlgren</a> at O&#8217;Reilly Media for teaching me about real-world embedded font support.)</p>
<p><em>Edited November 10, 2009 to include a pointer to <a href="http://en.wikipedia.org/wiki/DejaVu_fonts">DejaVu</a>.)</em></p>
]]></content:encoded>
			<wfw:commentRss>http://blog.threepress.org/2009/09/16/how-to-embed-fonts-in-epub-files/feed/</wfw:commentRss>
		<slash:comments>14</slash:comments>
		</item>
		<item>
		<title>Tools of Change twitter visualization</title>
		<link>http://blog.threepress.org/2009/02/15/tools-of-change-twitter-visualization/</link>
		<comments>http://blog.threepress.org/2009/02/15/tools-of-change-twitter-visualization/#comments</comments>
		<pubDate>Sun, 15 Feb 2009 18:51:42 +0000</pubDate>
		<dc:creator>Liza Daly</dc:creator>
				<category><![CDATA[geek]]></category>
		<category><![CDATA[toc]]></category>
		<category><![CDATA[twitter]]></category>
		<category><![CDATA[visualization]]></category>

		<guid isPermaLink="false">http://blog.threepress.org/?p=342</guid>
		<description><![CDATA[Geeks love raw data, so I couldn&#8217;t resist a text dump of all #toc tweets that occurred during the conference.
Here&#8217;s the quick visualization I threw together (warning, it loads very slowly):

It skips any images that are broken or any that were listed as having the Twitter default icon.  For some reason the raw data [...]]]></description>
			<content:encoded><![CDATA[<p>Geeks love raw data, so I couldn&#8217;t resist a <a href="http://toc.oreilly.com/2009/02/very-raw-dump-of-all-toc-2009.html">text dump of all #toc tweets</a> that occurred during the conference.</p>
<p>Here&#8217;s the quick visualization I threw together (warning, it loads very slowly):</p>
<p><a href="http://threepress.org/static/toctweets/"><img src="http://blog.threepress.org/wp-content/uploads/2009/02/picture-71-300x235.png" alt="TOC tweet visualization" title="TOC tweet visualization" width="300" height="235" class="aligncenter size-medium wp-image-343" /></a></p>
<p>It skips any images that are broken or any that were listed as having the Twitter default icon.  For some reason the raw data included a lot of default icons it shouldn&#8217;t have &#8212; for example, all of my tweets were listed with the default instead of my profile photo.  Those are missing.  I recommend starting with the XML instead (posted after I wrote this) and getting the profile icons directly via Twitter.</p>
<p>Source code that generates this from the raw text (not from the XML) follows:</p>
<p><span id="more-342"></span></p>
<pre class="brush: plain;">
#!/usr/bin/python
import re, copy, urllib, sys

# Pattern-match the twitter username
p = re.compile('^([^:]+):(.*)$')

data = []
tweet = None

for line in open('toc-tweets.txt'):

    # If we're not currently in a tweet, start a new record
    if not tweet:
        tweet = {}

    # Skip the useless relative date values
    if line.endswith('ago'):
        continue

    # This is an end-of-tweet marker, so push it on the stack
    # and reset the temporary datastore
    if line.startswith('*'):
        data.append(copy.deepcopy(tweet))
        tweet = None
        continue

    # Grab the user's image
    if line.startswith('http://'):
        tweet['img'] = line
        continue

    m = p.search(line)
    if m:
        # If we matched the regexps then we have a line containing a valid tweet
        tweet['name'] = m.group(1)
        tweet['message'] = m.group(2).replace('&amp;', '&amp;amp;')

# Put in chronological order
data.reverse()

print '''&lt;html xmlns=&quot;http://www.w3.org/1999/xhtml&quot;&gt;
  &lt;head&gt;
    &lt;meta http-equiv=&quot;Content-Type&quot; content=&quot;text/html;charset=UTF-8&quot; /&gt;
    &lt;title&gt;#toc timeline&lt;/title&gt;
    &lt;script src=&quot;http://www.google.com/jsapi&quot; type=&quot;text/javascript&quot;&gt;&lt;/script&gt;
    &lt;script type=&quot;text/javascript&quot;&gt;
      google.load(&quot;jquery&quot;, &quot;1.3&quot;);
    &lt;/script&gt;
    &lt;script src=&quot;jqueryui/jquery-ui-personalized-1.6rc6.min.js&quot; type=&quot;text/javascript&quot;&gt;&lt;/script&gt;
    &lt;style type=&quot;text/css&quot;&gt;
       .tweet span { display: none; width: 300px; height:200px;  }
       .tweet { display: inline; z-index: -1;}
       .drop { width: 240px; height: 135px; padding: 0.4em; position:absolute;background:white;z-index:99;}
       .drop h3 { margin: 0; padding: 0.4em; text-align: center; }

    &lt;/style&gt;
    &lt;link rel=&quot;stylesheet&quot; type=&quot;text/css&quot; href=&quot;jqueryui/theme/ui.all.css&quot;&gt;&lt;/link&gt;
    &lt;script type=&quot;text/javascript&quot;&gt;
    jQuery(document).ready(function() {
      $('.tweet').click(function() {
        $(this).find('span').toggle('fast');
      });
    });
    &lt;/script&gt;
   &lt;/head&gt;
&lt;body&gt;
'''

images = {}

for t in data:
    if 'default_profile' in t['img']:
        continue
    image = t['img'].replace('mini', 'bigger')
    if image not in images:
        sys.stderr.write(&quot;Checking %s\n&quot; % image)
        i = urllib.urlopen(image).read()
        if 'Error' in i:
            sys.stderr.write(&quot;Skipping...&quot;)
            continue
        images[image] = 1

    print '''
&lt;span class=&quot;tweet&quot;&gt;
  &lt;img src=&quot;%s&quot; alt=&quot;%s&quot; width=&quot;73&quot; height=&quot;73&quot; /&gt;
  &lt;span class=&quot;ui-widget-content ui-corner-all drop&quot;&gt;
    &lt;h3 class=&quot;ui-widget-header ui-corner-all&quot;&gt;&lt;a href=&quot;http://twitter.com/%s&quot;&gt;%s&lt;/a&gt;&lt;/h3&gt;
    &lt;blockquote&gt;%s&lt;/blockquote&gt;
  &lt;/span&gt;
&lt;/span&gt;
''' % ( t['img'].replace('mini', 'bigger'),
       t['name'],
       t['name'],
       t['name'],
       t['message'])

print '''
&lt;/body&gt;
&lt;/html&gt;
'''
</pre>
]]></content:encoded>
			<wfw:commentRss>http://blog.threepress.org/2009/02/15/tools-of-change-twitter-visualization/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>

