PETZOLD BOOK BLOG

Charles Petzold on writing books, reading books, and exercising the internal UTM


Recent Entries
< PreviousBrowse the ArchivesNext >
Subscribe to the RSS Feed

TODO: An EPUB Viewer for Windows 8

November 1, 2011
New York, N.Y.

For a couple years now I've seriously considered participating in National Novel Writing Month by joining hundreds of thousands of other crazy writers who spend the month of November writing a novel in 30 days. But not this year. This year I want to spend November in the somewhat related activity of coding an e-book reader for Windows 8.

Yesterday I discussed Phree Book Reader, a program I wrote for Windows Phone that lets you download, save, and read public-domain plain-text books from Project Gutenberg. I considered porting that program to Windows 8, but I think it would be more fun to do something completely new, and to go beyond plain text. The Windows 8 program will instead let you read books that comply with the EPUB standard. An EPUB is basically a ZIP file containing HTML files for each chapter (including CSS) as well as bitmaps and fonts.

I want to do this program in Windows 8 "Metro style" as a way to learn the API, but also because I received a nice little Windows 8 tablet from attending the Build conference in September, and it seems ideal for reading books. (Or rather, ideal in the home environment. I'm certainly not going to cart it around with me. I have a Windows Phone for that.)

I have no illusions that the hard part of this program will be the code that parses the HTML and CSS and lays out the pages. Fortunately, EPUBs use XHTML rather than HTML (so I can use XmlReader), and the subsets used in EPUB are very well defined. As everyone who examines the EPUB specification will agree, parsing and applying the CSS will be harder than the HTML.

This e-book reader will be as Metro-ish as I can possibly make it. (I'm even worried that it'll be so Metro that it won't feel comfortable in cities with populations fewer than 50 thousand people.) However, I intend for the EPUB/HTML/CSS parsing engine to be platform independent — or at least as platform independent as I can make it using C# and .NET. It would be nice to re-use this engine in Phree Book Reader 2.0 on Windows Phone, or in a Silverlight or WPF program if the need arises. These platforms are all similar, of course, but some crucial differences affect this engine, including the way you extract files from a ZIP package, determine font metrics, and what elements you'll use to assemble the page. (I've already noticed that the Windows 8 version of TextBlock doesn't include the FontSource property found in the Silverlight TextBlock, which allows you to reference an external font file accessible through a Stream. Will I instead be using DirectWrite?)

The tentative name for this program is The New Epublic, a silly twist on The New Republic, a forgotten 1877 satirical novel by William Hurrell Mallock. The subtitle — yes, since I'm coding this e-book reader during National Novel Writing Month, I want it to have a subtitle — is The Way We Read Now (a variation of the title of a much more famous novel).

For 16 days during the month of November, I'll be alone because Deirdre will in Provincetown at the Norman Mailer Writers Colony suffering for her art and getting her screenplay in shape. (With any luck, the movie will be released in 2013.) Her absence might not be good for me, but I think it'll be great for the program. The absence of another human being in the apartment means that I can basically work all day without the distracting needs of being sociable, or keeping regular waking/eating/sleeping hours.

Of course I'll be posting blog entries periodically with some Windows 8 revelations and/or rants.


Comments:

Looking forward to following you on your journey Charles !

— Sven, Wed, 2 Nov 2011 17:15:58 -0400

It would be really great if you could write a book on WinRT.

— nyi nyi, Wed, 2 Nov 2011 22:55:12 -0400

The only prerequisite is for my publisher to believe that the book will sell 25,000 copies in its first year.

It's as simple as that. — Charles

Dear Charles, I hope you will manage to back port EPUB support to Windows Phone against all obstacles if it is reasonable at all. Thank you!

— IL, Tue, 6 Dec 2011 07:47:13 -0500

Porting to the phone should be the easy part! — Charles

Greetings and happy new year!

I am interested in your 'New ePublic' venture. How's it coming along?

Any chance you'll have it available soon?

Respectfully,

Richard Drain, Sun, 8 Jan 2012 22:28:55 -0500

I've kind of hit a wall on this. I suspect I'll probably be going in another direction. — Charles


Recent Entries
< PreviousBrowse the ArchivesNext >
Subscribe to the RSS Feed

(c) Copyright Charles Petzold
www.charlespetzold.com