View Single Post
Old 10-16-2015, 11:39 AM   #55
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
`Un-Force user font-family in KePubs`

The KePub reader is very heavy-handed when a font-family other than 'Publisher Default' is selected from the font menu. This patch makes the KePub reader use a lighter-handed approach similar to the ePub reader, letting the user select a font, but allowing the publisher to overide it.

The first alternative just uses the user-selected font at <body> level, the publisher can override anything else. The second alternative forces the user-selected font to be used at <body> and <p> level, which is similar to how the unpatched ePub reader does it.

I haven't tested this patch much, it seems to work but let me know if you see any unexpected side effects.

Paste into libnickel.so.1.0.0.patch:
Spoiler:
Code:
<Patch>
patch_name = `Un-Force user font-family in KePubs`
patch_enable = `yes`
# Multi-version patch: 3.3.0 - 3.18.0+
#
# This patch allows the font-family set by the publisher in the kepub
# stylesheet to override the font-family selected by the reader from the device.
#
find_base_address = `*\0 \0{\0 \0f\0o\0n\0t\0-\0f\0a\0m\0i\0l\0y\0:\0 \0%\01\0 \0!\0i\0m\0p\0o\0r\0t\0a\0n\0t\0;\0 \0}\0\n\0`
#
# Alternative 1: (similar to ePub with `Un-force font-family override p tags`)
#
#     * { font-family: %1 !important; }\n
# --> body{font-family:%1 !important; }\n
#
replace_string = 0000, `*\0 \0{\0 \0f\0o\0n\0t\0-\0f\0a\0m\0i\0l\0y\0:\0 \0%\01\0 \0!\0i\0m\0p\0o\0r\0t\0a\0n\0t\0;\0 \0}\0\n\0`, `b\0o\0d\0y\0{\0f\0o\0n\0t\0-\0f\0a\0m\0i\0l\0y\0:\0%\01\0 \0!\0i\0m\0p\0o\0r\0t\0a\0n\0t\0;\0 \0}\0\n\0`
#
# Alternatve 2: (Similar to ePub default)
#
#     * { font-family: %1 !important; }\n
# --> body,p{font-family:%1!important;}\n
#
#replace_string = 0000, `*\0 \0{\0 \0f\0o\0n\0t\0-\0f\0a\0m\0i\0l\0y\0:\0 \0%\01\0 \0!\0i\0m\0p\0o\0r\0t\0a\0n\0t\0;\0 \0}\0\n\0`, `b\0o\0d\0y\0,\0p\0{\0f\0o\0n\0t\0-\0f\0a\0m\0i\0l\0y\0:\0%\01\0!\0i\0m\0p\0o\0r\0t\0a\0n\0t\0;\0}\0\n\0`
</Patch>
GeoffR is offline   Reply With Quote