View Single Post
Old 08-09-2015, 03:33 AM   #69
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

The EPUB reader tries to use the Adobe "CourierStd" font when font-family:monospace is encountered, but it uses the wrong pathnames and that font is not supplied with Kobo devices anyway, and so the default reading font gets used even if it is not monospaced (i.e. Georgia is used if "Publisher Default" is selected.)

This patch makes the EPUB reader use a font named "Courier" (or beginning with "Courier") as the default monospace font. You can change "Courier" in the replacement string to another name if you wish, but it must be no more than 7 characters long.

For example the free Courier Prime font can be used, just rename the files "Courier Prime.ttf" "Courier Prime-Italic.ttf" "Courier Prime-Bold.ttf" "Courier Prime-BoldItalic.ttf" as usual for sideloaded fonts.

This patch should work on any firmware from version 3.3.0 onwards, but I've only tested it with firmware version 3.16.0.

`Default ePub monospace font (Courier)` patch (paste into librmsdk.so.1.0.0.patch):
Spoiler:
Code:
<Patch>
patch_name = `Default ePub monospace font (Courier)`
patch_enable = `yes`
# Multi-version patch: 3.3.0 - 3.16.0+
#
find_base_address = `CourierStd.otf`
replace_string = 0000, `CourierStd.otf`, `normal/Courier`
find_base_address = `CourierStd-Bold.otf`
replace_string = 0000, `CourierStd-Bold.otf`, `bold/Courier`
find_base_address = `CourierStd-Oblique.otf`
replace_string = 0000, `CourierStd-Oblique.otf`, `italic/Courier`
find_base_address = `CourierStd-BoldOblique.otf`
replace_string = 0000, `CourierStd-BoldOblique.otf`, `bolditalic/Courier`
</Patch>


Edit: After further testing it appears that the font names don't have to match exactly, they just have to start with the name in the patch. So the patch above will work with any sideloaded font that has a name beginning with "Courier", I've edited the description above to reflect this discovery.

Below is the same patch modified to work with HP's free "Dark Courier" font.

`Default ePub monospace font (Dark Courier)` patch (paste into librmsdk.so.1.0.0.patch):
Spoiler:
Code:
<Patch>
patch_name = `Default ePub monospace font (Dark Courier)`
patch_enable = `yes`
# Multi-version patch: 3.3.0 - 3.16.0+
#
find_base_address = `CourierStd.otf`
replace_string = 0000, `CourierStd.otf`, `normal/Dark`
find_base_address = `CourierStd-Bold.otf`
replace_string = 0000, `CourierStd-Bold.otf`, `bold/Dark`
find_base_address = `CourierStd-Oblique.otf`
replace_string = 0000, `CourierStd-Oblique.otf`, `italic/Dark`
find_base_address = `CourierStd-BoldOblique.otf`
replace_string = 0000, `CourierStd-BoldOblique.otf`, `bolditalic/Dark`
</Patch>


Edit2: The patch itself seems to work okay if there are multiple fonts beginning with "Courier", whichever one the Kobo firmware happens to choose gets used as the default monospace font. However the EPUB reader seems to have problems selecting a font from the dropdown menu if it has a name that is the prefix of another font name. I found that if I had both "Courier Prime" and "Courier Prime Sans" fonts on my Glo, I could not select "Courier Prime", I just got "Courier Prime Sans" when I tried. Both fonts worked fine if the other was not present.

Last edited by GeoffR; 08-10-2015 at 05:57 AM. Reason: Problem with font names that are a prefix of another font name.
GeoffR is offline   Reply With Quote