Showing posts with label epub. Show all posts
Showing posts with label epub. Show all posts

Thursday, May 10, 2012

The Return of Zpub

While comparing the screenshots of glinks and bunjalloo, I was reminded of my old zpub post.  At the time I hadn't really dug into the links code very much, so I just sorta settled for a so-so reading experience.  I'd thought the epub text in glinks was somewhat small and ugly compared to netsurf.  But since netsurf requires the "mouse" I was a bit aprehensive about using it for an ereader.  I also remembered that dronz had tweaked his glinks config for ereading, so I decided to do a little experimentation with zpub and glinks.

The first change I made was to bump up the text size to something closer to the fonts used in a typical paperback book.  I'm pretty happy with an html-user-font-size setting of 18, but 16 is also not too shabby.  With the larger font, it makes sense to reduce the html-margin setting to 1 character to waste a minimal amount of space on the sides.  To bad you can't set it to 1 or 2 pixels.

While I was working on the margins I decided to see what I could do about that big fat ugly scroll bar.  The default G_SCROLL_BAR_WIDTH setting in setup.h is 12 pixels, which is extremely wasteful on the zipit.  Simply reducing it by 4 pixels gives me another full line of text with a font size of 18.

The other thing that really bugs me about glinks is the ugly default battleship gray background color.  You can change the colors of the menus, status bars, and even the scroll bar, but the html page background color must be set with in the document with a <body bgcolor="#FFFFDD"> tag or else you get the hard coded default_bg_g color from the default.c file.  I may try to code up an html-default-bgcolor command line and config file option to set this at runtime, but for now I just compiled in a yellow tinged off white color #FFFFDD that reminds me an old paperback book.

Another thing I noticed was the occasional odd characters in the text. Turns out the books I fetched from Project Gutenberg are utf8 formatted. I wouldn't be surprised if all epub documents are utf8.  Gotta review the specs someday.  Anyhow, I simply added the html-assume-codepage utf8 setting to the zpub script and now all is right with the text.  Check it out.
Remember how it used to look?  The new look is sooo much more warm and inviting, and actually displays even better on the zipit itself because the hardware rotated screen orientation washes out some of the yellow and possibly better matches my glinks subpixel anti-aliasing orientation setting.  Compare to this.


Gotta see if I can add that links command line option, then get the goodies posted and resume work on the bunjalloo code.

Update:  That turned out to be pretty easy, just a few ifdefs in the default.c file.  But now I've got a few more ideas.  I read about a third of the "Little Fuzzy" novel last night, and when I put down the zipit I realized the links bookmark system is probably inadequate for ereading.  I'd really like to save the scroll bar position so I can resume where I left off.  I'm gonna see if I can use the M and R keys to Memorize and Recall a scroll bar bookmark.  I might also look into defining the L and D keys in links to Lighten and Darken the LCD backlight for an adjustable day or night reading experience.  Either that or I'll have to setup the keymap so I can switch to another virtual terminal to adjust the lights and maybe check the battery level.

Update 2:  I finally finished reading my first full e-novel on the zipit and I can honestly say the experience was actually better than a paperback book in one way because I was able to pocket the zipit and take it with me.  I did find and fix a bug in zpub during my test read that briefly prevented me from viewing the 2nd half of the novel.  The M and R key scrollmark patch was fairly simple, and really made it easy to put down the zipit and pick it up again later to continue reading.  I decided against patching dimmer keys into links because that should be done at a system level so all apps can benefit.  I just need to work out which key combos make sense for all apps.

Here's the updated IZ2S zpub and links executables:  zpub2-iz2s.zip

Here's the modified links sources:  links-sdl-iz2s-zpub.tar.bz2
Here's a comprehensive patch for links-2.3 on the zipit:  links-2.3-zipit.patch

And here's a patch with just the ereading modifications.  http://pastebin.com/weJbzHWT

A jffs version will come later.  I need to make a zpub-lite that works without bash, and bc.  And I'll either have to provide a mini unzip executable, or build zpub-lite as an executable so I can use zlib. Maybe another mcb...

Thursday, September 8, 2011

Back to the Books

A long time ago, possibly in a galaxy far far away, I bought a couple of old H. Beam Piper books and started reading them.  Then Return of the Jedi came to the theaters and ruined it for me.  The Little Fuzzy characters prominently showcased on all the book covers reminded me way too much of those insipid ewoks!  So I packed them all up, never to be seen again until recently when I stumbled upon them buried in the attic.  I was well over my ewok phobia by now; watching the even more insipid Jar-Jar character with the kids had cured me of that eons ago.  So, to make a long story short, I finally finished reading the books, and enjoyed them enough to start searching for more.

Well, I visited the local bookstore and they had nothing so I went shopping on the internet.  Apparently many of Piper's books have lapsed into the public domain and are available for free at Project Gutenberg.  WhoHoo!  Score!  So I nabbed a few of the zipped .txt files and started reading them on the zipit with greader2x.  Not bad, but they're also available in epub format, and some of those come with pictures!  I had to have it.

After a tiny bit of research I discovered that epub is really just a zipfile with some xml packaging around html formatted books and/or chapters.  Once unzipped it can be read in a browser.  I found the ebook-tools C library which I might use someday to add epub support to greader2x.  But meanwhile there's epub-read.sh, a simple shell script to unzip, parse, and browse the contents of an epub file. 

The epub-read.sh script uses frames and javascript to provide a the table of contents, so I simplified it a bit for the somewhat limited browsers available on the zipit.  And thus zpub was born.  It works ok in glinks, but the text is kinda small for me.


You can edit the script and replace the call (near the end) to the glinks browser with links for text only epub reading, or with netsurf for something that looks more modern.

 
zpub.zip