View Single Post
Old 08-12-2015, 03:12 AM   #31
GeoffR
Wizard
GeoffR ought to be getting tired of karma fortunes by now.GeoffR ought to be getting tired of karma fortunes by now.GeoffR ought to be getting tired of karma fortunes by now.GeoffR ought to be getting tired of karma fortunes by now.GeoffR ought to be getting tired of karma fortunes by now.GeoffR ought to be getting tired of karma fortunes by now.GeoffR ought to be getting tired of karma fortunes by now.GeoffR ought to be getting tired of karma fortunes by now.GeoffR ought to be getting tired of karma fortunes by now.GeoffR ought to be getting tired of karma fortunes by now.GeoffR ought to be getting tired of karma fortunes by now.
 
GeoffR's Avatar
 
Posts: 3,821
Karma: 19162882
Join Date: Nov 2012
Location: Te Riu-a-Māui
Device: Kobo Glo
Default ePub monospace font

Kobo e-ink readers don't currently come with any monospaced fonts pre-installed, and so it is necessary to sideload one. However the choice of which to use as a default when an ePub contains the generic style font-family:monospace; is hard-coded to Adobe's proprietary Courier Std font, and when that font inevitably fails to load the EPUB reader falls back to the initial font selected by the user (or Georgia if "Publisher Default" is selected), which is probably not monospaced.

The `Default ePub monospace font` patch lets the EPUB reader use the first font it finds with a name beginning "Courier" as the default monospace font. So for example if the free Courier Prime font is sideloaded* (and no other sideloaded font name begins with "Courier") then that will be used.

The screenshots below (Glo, 3.16.0) show which fonts the EPUB reader uses for the font-family styles initial/unspecified, serif, sans-serif, and monospace in the attached ePub. The device has the Courier Prime font sideloaded, and Kobo Nickel is the font selected from the drop-down font menu:

1. Unpatched (initial=Kobo Nickel, serif=Georgia, sans-serif=Avenir, monospace=Kobo Nickel.)
2. Patched (initial=Kobo Nickel, serif=Georgia, sans-serif=Avenir, monospace=Courier Prime.)
Click image for larger version

Name:	unpatched.png
Views:	2561
Size:	40.4 KB
ID:	140956 Click image for larger version

Name:	patched.png
Views:	2578
Size:	42.0 KB
ID:	140957

(The default monospace font can also be set without patching by modifying each ePub's stylesheet, which can be done automatically if sideloading via Calibre.)

(* To sldeload the Courier Prime font, rename the files to "Courier Prime.ttf" "Courier Prime-Italic.ttf" "Courier Prime-Bold.ttf" "Courier Prime-BoldItalic.ttf" as usual. Note that this font has the incorrect PANOSE weight set. This doesn't cause any problem for the EPUB reader, but if you want to use the Courier Prime font in KePubs then you might want to use a program like fontforge to correct the PANOSE weight from thin to book or bold as appropriate.)

(Note that this patch can also be modified to use fonts with a different name, such as HP's Dark Courier.)
Attached Files
File Type: epub font-family-defaults.epub (2.0 KB, 997 views)

Last edited by GeoffR; 09-07-2015 at 03:48 AM. Reason: Added note about incorrect PANOSE weight in Courier Prime font
GeoffR is offline   Reply With Quote