View Single Post
Old 11-16-2016, 07:58 PM   #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
`KePub optimizeLegibility default`

In this thread jackie_w showed how to enable ligatures in KePub books by modifying the book's stylesheet. This patch does the same thing but modifies the device's built-in stylesheet, so it should work with existing sideloaded KePubs and also KePubs synced direct from Kobo.

Edit: See the screenshots in this post for some of the other effects I've noticed. Beware, there are some bad spacing effects with fully-justified text.

This patch should work on all firmware versions from 3.16.0 to 4.1.7729 and maybe later versions too.

`KePub optimizeLegibility default` (paste into libnickel.so.1.0.0.patch):
Spoiler:
Code:
<Patch>
patch_name = `KePub optimizeLegibility default`
patch_enable = `yes`
# Multi-version patch: 3.16.0 - 4.1.7729+
#
## This patch adds the following style to the built-in KePub stylesheet:
##
##   body{text-rendering:optimizeLegibility}
##
## One of the effects is to enable the use of standard ligatures in KePub books
## by default, if the selected fonts support them. There might be other effects.
#
find_base_address = `\t\0.\0K\0B\0A\0u\0t\0h\0o\0r\0A\0n\0n\0o\0t\0a\0t\0i\0o\0n\0,\0 \0.\0K\0B\0A\0u\0t\0h\0o\0r\0A\0n\0n\0o\0t\0a\0t\0i\0o\0n\0C\0o\0n\0t\0i\0n\0u\0e\0d\0 \0{\0 \0b\0a\0c\0k\0g\0r\0o\0u\0n\0d\0-\0c\0o\0l\0o\0r\0:\0 \0t\0r\0a\0n\0s\0p\0a\0r\0e\0n\0t\0 \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0g\0M\0o\0d\0e\0=\0"\0h\0o\0r\0i\0z\0o\0n\0t\0a\0l\0-\0t\0b\0"\0]\0{\0b\0o\0r\0d\0e\0r\0-\0b\0o\0t\0t\0o\0m\0:\02\0p\0x\0 \0s\0o\0l\0i\0d\0 \0b\0l\0a\0c\0k\0!\0i\0m\0p\0o\0r\0t\0a\0n\0t\0}\0b\0o\0d\0y\0{\0t\0e\0x\0t\0-\0r\0e\0n\0d\0e\0r\0i\0n\0g\0:\0o\0p\0t\0i\0m\0i\0z\0e\0L\0e\0g\0i\0b\0i\0l\0i\0t\0y\0}\0`
#
</Patch>


If you are using the `KePub full justification default` patch then you'll need to replace it with this new version, or else the `KePub optimizeLegibility default` patch won't apply:

`KePub full justification default` (replace the version in libnickel.so.1.0.0.patch):
Spoiler:
Code:
<Patch>
patch_name = `KePub full justification default`
patch_enable = `yes`
# Multi-version patch: 3.16.0 - 4.1.7729+
#
## This patch makes full justification the default for KePub books by adding the
## following to the built-in KePub stylesheet:
##
##   body{text-align:justify}
##
## This only sets the default, if the publisher has set the justification in the
## book's stylesheet then that will override the default, and so you might still
## need to use the justify button on the Aa menu to set full justification.
##
## The advantage of this patch is that using the justify button, which also
## forces some things such as headings to be fully justified instead of
## centred, can be avoided for some books.
#
find_base_address = `.\0K\0B\0H\0i\0g\0h\0l\0i\0g\0h\0t\0i\0n\0g\0,\0 \0.\0K\0B\0S\0e\0a\0r\0c\0h\0R\0e\0s\0u\0l\0t\0 \0{\0 \0b\0a\0c\0k\0g\0r\0o\0u\0n\0d\0-\0c\0o\0l\0o\0r\0:\0 \0#\0C\06\0C\06\0C\06\0`
#
replace_string = 0000, `.\0K\0B\0H\0i\0g\0h\0l\0i\0g\0h\0t\0i\0n\0g\0,\0 \0.\0K\0B\0S\0e\0a\0r\0c\0h\0R\0e\0s\0u\0l\0t\0 \0{\0 \0b\0a\0c\0k\0g\0r\0o\0u\0n\0d\0-\0c\0o\0l\0o\0r\0:\0 \0#\0C\06\0C\06\0C\06\0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00\0%\0!\0i\0m\0p\0o\0r\0t\0a\0n\0t\0;\0-\0w\0e\0b\0k\0i\0t\0-\0t\0e\0x\0t\0-\0c\0o\0m\0b\0i\0n\0e\0:\0i\0n\0h\0e\0r\0i\0t\0!\0i\0m\0p\0o\0r\0t\0a\0n\0t\0}\0.\0K\0B\0S\0t\0a\0c\0k\0K\0e\0y\0w\0o\0r\0d\0 \0a\0{\0c\0o\0l\0o\0r\0`
#
replace_string = 1D8, `.\0K\0B\0S\0t\0a\0c\0k\0K\0e\0y\0w\0o\0r\0d\0 \0a\0 \0{\0 \0c\0o\0l\0o\0r\0:\0 \0b\0l\0a\0c\0k\0 \0!\0i\0m\0p\0o\0r\0t\0a\0n\0t\0;\0 \0}\0 \0`, `:\0b\0l\0a\0c\0k\0!\0i\0m\0p\0o\0r\0t\0a\0n\0t\0}\0b\0o\0d\0y\0{\0t\0e\0x\0t\0-\0a\0l\0i\0g\0n\0:\0j\0u\0s\0t\0i\0f\0y\0}\0 \0 \0 \0 \0 \0 \0`
#
# Fix typo in annotations styles: KBAuthorAnnotation --> .KBAuthorAnnotation
replace_string = 0102, `\x20`, `.`
</Patch>

Last edited by GeoffR; 11-17-2016 at 06:14 PM. Reason: See the screenshots ...
GeoffR is offline   Reply With Quote