eReader: ePub Font Customization with PRS+ and Removing Embedded Fonts From ePub Books

So you've bought a Sony PRS-950 in the Best Buy clearance sales and you're just now noticing that the *one* thing you can't easily customize on the device is the default font used for ePub books. We can fix that. All we have to do is load a custom environment onto the device and then you're good to start adding as many fonts as you want.

You will need:
  1. A Sony PRS-950 eReader. 
  2. The Sony PRS+ installation file for your eReader. You can download the file here -- you want the PRSP_950_2.0.12beta_setup.exe file.
  3. The Notepad++ program for your desktop PC.
  4. A font-family of your choice in .ttf extension form (true type font). (Update: I've been informed that .otf files will also work, but I haven't tried them.) You really want a font-family with four versions: Regular, Bold, Italic, and BoldItalic. If you don't get all four, nothing bad will happen except that you won't have a uniform font across those four options -- you'll be reading along in Verdana or whatever and suddenly the text will switch to Times New Roman for the BoldItalic bits. If you can live with that, then grab whatever fonts you want; if you can't live with font-changes, be sure to select a font that comes in those four styles. A good place for free fonts is DaFont; if you're addicted to Windows fonts, you can pillage them from your C:/Windows/Fonts directory.
OK. Ready? Let's go.

PRS+ Installation

First we're going to install PRS+ to your Sony reader. PRS+ is a custom firmware -- it's third-party developed software that loads to your device and lets you do cool things like change the default font. Like everything that's worth doing to an eReader, doing this almost certainly voids your warranty, has a non-zero chance of bricking your device, and should only be installed while sober. I didn't write this code, don't know the people who did, and have only installed this once -- so I take no responsibility for anything that might go wrong as a result of reading my blog, etc.

That out of the way, plug your Sony reader into your desktop computer. Double-click the PRSP_950_2.0.12beta_setup.exe file. The PRS+ installer will check your reader's firmware and tell you to press "Next" to start the installation. This is the point of no return -- pressing next will install the PRS+ firmware on your device.


Fonts Folder

After the installation, open the "READER" directory on your computer -- this is the internal memory for the Sony reader.


The READER drive will have a new folder in it called "database" (and may have the .calibre files if you've used Calibre with the reader before now). We need to add a folder called "fonts" to this directory, so do so now.


Load the font(s) you've decided to try out on your device. You can name the font files whatever you want -- I've decided to name mine all according to a set style (X-Regular.ttf, X-Bold.ttf, etc.) so that the next step is easier, but you can name them whatever you want.

ePub CSS Folder

Now open the database folder that is in the reader directory and dig down until you reach the directory path READER\database\system\PRSPlus\epub. Here is where we are going to need to put some css files to let the reader know what font family to use.


Create a new txt file directory and open it in Notepad or Wordpad or whatever text editor you like.
Copy and paste the following into the text file:

@font-face {
font-family: "Charis";
font-weight: normal;
font-style: normal;
src: url(res:///Data/fonts/Charis-Regular.ttf);
}

@font-face {
font-family: "Charis";
font-weight: bold;
font-style: normal;
src: url(res:///Data/fonts/Charis-Bold.ttf);
}

@font-face {
font-family: "Charis";
font-weight: normal;
font-style: italic;
src: url(res:///Data/fonts/Charis-Italic.ttf);
}

@font-face {
font-family: "Charis";
font-weight: bold;
font-style: italic;
src: url(res:///Data/fonts/Charis-BoldItalic.ttf);
}

body {
font-family: "Charis";
}


The above is my CSS for the Charis font. You're going to need to change the red and the green text for your fonts to work. Let's talk about what the code means:

@font-face {
font-family: "Charis";
font-weight: normal;
font-style: normal;
src: url(res:///Data/fonts/Charis-Regular.ttf);
}

The red text is the name of the font. This is going to be something like Arial, Helvetica, Verdana, Charis, etc. Change this to the name of whatever font you are using. The blue text is the weight of the text -- normal or bold. Similarly, the orange text is the style of the text -- normal or italic. The green text is the location of the font file you've stored in the "fonts" directory. Change this to the font file names you're using, but remember to keep the ".ttf" extension. (Note that you also need to get the cAsEs CoRrEcT.) (Update: If you are using .otf fonts, then change the extension in the CSS to .otf accordingly.)

Basically, all the snippet above is saying is that when the reader sees text that is normal-weight and normal-style, the reader should display the Charis font that lives at the green location.

After making your necessary changes, save the text file and exit your text editor. Now rename the file so that it has a ".css" extension instead of a ".txt" extension. The name of the file doesn't really matter, so I call mine "userstyle.FONTNAME.css".

Encoding with Notepad++

One last step before we're done with all this code. Open up Notepad++. Select File --> Open, and navigate to the CSS file you just saved. Once the CSS file has loaded, open the Encoding menu.


We want the encoding to be either "Encode in UTF-8 without BOM" or "Encode in ANSI". If the file is "Encode in UTF-8" (the third menu option), then the file won't be handled properly by the reader. I use the "Encode in UTF-8 without BOM" option, so that's what I recommend you do. Select that option, and then save the file. Close Notepad++ -- you're done with code.

Using the Font

Unplug your device from the computer and wait for everything load up. Since PRS+ has been installed, you'll notice that the front menu looks slightly different -- that can be customized to your heart's delight later. In the mean time, go to "Settings" down at the bottom right-corner of the home screen.

The first option on the Settings menu should now be "PRS+ Settings". Select that, then select the fifth option down, "Book Viewer Settings". Select "User EPUB Style" and note that your CSS file ("userstyle.FONTNAME.css") should be listed there. Select that puppy.


From now on, when you load up an ePub with your reader, you should have whatever font you've selected as the default. If you ever want to change the default, you can just go back through the menu system again.

But wait, there's one more thing...

See that long title up there? We've only covered half of it. The other half -- removing embedded fonts from epubs -- is necessary if you want to ensure that all your epubs are using the default font you just installed.

What's an embedded font? Well, here's the short version. Sometimes ebooks come with their own special encoding that ensures that a specific font is used with that book. This font usually overrides the e-Reader defaults -- so if you've got your heart set on Verdana and an author throws Times New Roman at you, you're stuck with it unless you modify the epub to remove that embedded font.

Now, you could manually recode all your epub books, but that's a pain and a half, and we have a workaround. See, the trick is that in order for an embedded font to "stick", the device has to have the embedded font available. Since the publisher doesn't know for sure that your specific e-Reader will carry their font, they have to include the font inside the epub file. (An epub file is basically a compressed file -- if you want to see a neat trick, take an epub file, make a copy, and rename the copy's extension to ".zip". Unzip it with WinZip or WinRar and look around at the contents. Neat!)

If we take the font file out of the epub file, then the css in the epub that points to that font file will fail and most devices will just quietly revert to the default device font. And there is a swiffy Calibre program that will automate all that.

So, here is what you will need:
  1. The Calibre program to store your epubs.
  2. This Calibre Modify-epub plugin, courtesy of Kiwidude.
Install Calibre if you aren't using it already and drop your epub files into the library management. Now, click the big Preferences icon on the menu bar and select Plugins from the menu list.


Once in the Plugins menu, select Add a New Plugin at the bottom of the screen.


Select the Modify-epub.zip file and Calibre will install the plugin. When the installation is finished, you will see a Modify ePub icon in the menu bar (if you selected that the menu bar icon be installed with the plugin).


Select an epub (or all of them, if you like) in your Calibre library, and press the Modify ePub icon. The modification dialogue will pop up; check "remove embedded fonts".


Then press "OK". If the selected epub(s) do not contain embedded fonts, you'll get a little message saying that no epubs were changed; if embedded fonts were found and removed, a text dialogue will pop up telling you which epubs were changed and what font was removed.

Important things to remember...
  • The PRS+ custom firmware may "disappear" if you reboot your reader with an SD card still in the slot. Don't panic -- just turn off the reader, remove the SD card, and boot up the device and PRS+ should be "back". Then you can plug your SD card back in as normal. I have no idea why this happens, but I have seen it happen once, so don't worry too much if you see it too.
  • The Modify ePub plugin does not change the epub CSS, it just removes the font files. This means that the epub CSS is pointing to a font that doesn't exist any more. The Sony behavior in these cases is to revert to the default font; other readers may break. Test this out (and backup your library) before converting everything wholesale. 
  • This entire guide is just me showing how I finally got all this to work. I didn't invent any of this, can't take credit for it, and can only provide rudimentary trouble shooting. Credit must go to the clever folks at Mobile Reads for helping me get this far. If you like these methods and can afford to patronize the arts, please donate to the PRS+ team, the Calibre team, and/or Kiwidude to support their coding efforts.

9 comments:

Lstroyan said...

Wow -- thanks for your work writing this all up so thoroughly!

One note--I am pretty sure PRS+ isn't firmware, just an additional layer that can be removed if desired. I installed it to get other features and love it, so haven't actually tried, but my impression is that it's not like rooting it or anything.

rac said...

Great write-up. Couple suggestions:
- Include a zipfile of fonts and css texts if possible? Is there an open source version of Charis, say on fonts.ubuntu.org?
- Include attributions to other. A lot of this information is from Mobileread forums so it'll be great to credit to names and places of where the info came from. But the awesome writeup is all yours.

Ana Mardoll said...

Well, just because a font is free doesn't mean I have the right to redistribute it on my blog, I'm afraid. Hopefully the instructions are clear enough that  people can download their desired fonts as needed. As for the Mobile Read forums, the information gathered for this post was spread out over three or four threads, which is why I didn't directly link to anything. I believe I gave credit in-post to all the developers, though. Thanks! :)

Lisa Stroyan said...

The link to the modify epub plugin doesn't work anymore. I did find an updated version here http://www.mobileread.com/forums/showthread.php?t=134249&page=11 but it probably won't stay up-to-date long.

Ana Mardoll said...

Thank you, Lisa! It looks like the attachments are  removed as new versions are created? So I think you're right that the link is going to keep moving. :(

Bro Pete said...

Thank you very much Ana. I needed a simple step by step procedure. Thanks again for holding my hand as I stepped into a whole new world of modifying my reader.

Ana Mardoll said...

No problem! I love my Sony reader so much, so I'm happy to help someone else with theirs. :)

Yo said...

Ana, it´s possible to ad a line setting margins? In that case, where?

Thank you very much

EldRick said...

"The READER drive will have a new folder in it called "database" (and may have the .calibre files if you've used Calibre with the reader before now). We need to add a folder called "fonts" to this directory, so do so now. "

This second sentence seems to say that you need READER/database/fonts, which, of course, does not work.

You might want to modify the description to say "You need to create the directory /fonts in the top level of the READER, at the same level as the /database folder."

Post a Comment