View Single Post
Old 01-04-2012, 02:05 PM   #111
duncann
Member
duncann began at the beginning.
 
Posts: 23
Karma: 12
Join Date: Feb 2011
Device: PRS-950, T1
Here's what I do to change my font at will for all of my 124 epubs on an unrooted T1:

I created a 'fonts' directory at the root when plugged into a windows machine. Inside this folder I put all of the fonts I want to use. I then created a simple batch file asking which font I want to use. The batch file copies each of the four font variants into normal.otf, italic.otf, bold.otf, and bolditalic.otf.

Now the hard part about this is modifying each epub with the proper @font entries:
Code:
@font-face { font-family: "Serif"; font-weight: normal; font-style: normal; src: url(res:///ebook/fonts/../../mnt/sdcard/fonts/normal.otf); }

@font-face { font-family: "Serif"; font-weight: bold; font-style: normal; src: url(res:///ebook/fonts/../../mnt/sdcard/fonts/bold.otf); }

@font-face { font-family: "Serif"; font-weight: normal; font-style: italic; src: url(res:///ebook/fonts/../../mnt/sdcard/fonts/italic.otf); }

@font-face { font-family: "Serif"; font-weight: bold; font-style: italic; src: url(res:///ebook/fonts/../../mnt/sdcard/fonts/bolditalic.otf); }
I also have custom @page, body, div, and p settings for each epub:
Code:
@page { margin: 0em .25em 0em .25em }

body { display: block; margin: 0 0 0 0; padding: 0 0 0 0; border: 0 0 0 0; text-align: justify; font-family: "Serif"; font-size: 0.9500em; line-height: 1.0525em; }

p, div { display: block; margin: 0 0 0 0; padding: 0 0 0 0; border: 0 0 0 0; orphans: 0; widows: 0; }
This may sound like a lot of tedious work to modify 124 epubs in this way, but it wasn't actually that bad. In addition to my library residing on my readers (950 and T1), it also resides on my computer with a folder structure created using Calibre with the template '{authors}/{series}/{authors} {pubdate} {series} {series_index} {title}' (the same folder structure exists on my readers as well). So I wrote another batch file to decompress each epub into another folder named 'decompressed'. I used 7zip for doing this. I then opened one of the epub's css file in ultraedit and did a 'replace in files'. Ultraedit has a pretty powerful search and replace engine and worked out quite well for what I wanted to do. I did run into one problem where some of the css's line terminators were UNIX, some DOS, and some MAC. So I had to do the same replace three different times. Since most were UNIX I saved all as UNIX line terminators for future ease of editing.

Once all that was done, the batch file I wrote earlier that decompresses the epubs, also recompresses them all into a folder named 'recompressed'. So I run that. Then I fire up Calibre, make a new library from the 'recompressed' folder, and either/both save to disk/send to device.

Now all I have to do to change the font is connect the T1 to my computer, engage data transfer mode, open the fonts directory on the T1, and run the batch file that changes the fonts.

Maybe someone is looking for a similar solution, so if this helps anyone, great. If anyone else has some other ideas to make this easier that would be welcome. For instance, I don't know very much at all about linux, but I had the idea that if a script similar to the fonts.bat file could be written and executed on a rooted T1, then the device wouldn't have to be connected to a computer to change the font. I believe this method is similar to how PRS+ changes the user css style sheet.
duncann is offline   Reply With Quote