This is a replacement for the `KePub optimizeLegibility deafult` patch I posted in
post #55, it allows the text-rendering style to be set to either optimizeSpeed or optimizeLegibility. optimizeSpeed is the default, you can change it to optimizeLegibility by uncommenting the line at the end of the patch.
See
this thread for some discussion of the effects of these settings. In short, from what I have seen fo far:
optimizeSpeed disables kerning and fixes the em-dash justification problem.
optimizeLegibility enables ligatures and kerning, and fixes the em-dash justification problem, but causes additional word- and letter-spacing problems in justified text.
(The em-dash justification problem is where lines containing em-dashes, ellipses, and some other special characters sometimes have a ragged right margin.)
This patch should work on all firmware versions from 3.16.0 to 4.1.7729 and maybe later versions too.
`KePub text-rendering options` (paste into libnickel.so.1.0.0.patch):
Spoiler:
Code:
<Patch>
patch_name = `KePub text-rendering options`
patch_enable = `yes`
# Multi-version patch: 3.16.0 - 4.1.7729+
#
## This patch adds one of the following styles to the built-in KePub stylesheet:
##
## body{text-rendering:optimizeSpeed }
## body{text-rendering:optimizeLegibility}
##
## Both options have the effect of fixing the problem with fully-justified text
## that sometimes results in a ragged-right margin on lines that contain an
## em-dash, ellipsis or other special character.
##
## The optimizeSpeed option disables kerning, even if the font has "old-style"
## kern tables.
##
## The optimizeLegibility option enables standard ligatures and GPOS kerning if
## the selected fonts support them, i.e. "old-style" kern tables are not needed.
##
## BEWARE: The optimizeLegibility option results in some quite uneven word and
## letter spacing when reading fully-justified text.
##
## (optimizeSpeed is the default, see the option at the end of this patch to
## choose optimizeLegibility instead.)
#
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 \0!\0i\0m\0p\0o\0r\0t\0a\0n\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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\0S\0p\0e\0e\0d\0 \0 \0 \0 \0 \0}\0`
#
# Uncomment the following line to choose the optimizeLegibility option instead:
#replace_string = 40A, `S\0p\0e\0e\0d\0 \0 \0 \0 \0 \0`, `L\0e\0g\0i\0b\0i\0l\0i\0t\0y\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 text-rendering options` 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 \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