View Single Post
Old 08-22-2015, 12:19 PM   #25
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
New `Force user line spacing in ePubs` patch.

This patch prevents the EPUB reader from recognising the line-height or font styles, which should make it impossible for the publisher to override the line spacing set from the device's adjustment slider. It will have bad effects on the formatting of many ePubs, the same as stripping the line-height and font styles during a calibre conversion does.

I don't recommend using this patch, but for those of you who are already taking the drastic step of routinely stripping line-height and font styles with Calibre before slideloading the book, this alternative is no worse and should also work for DRM ePubs.

The patch is in two parts, both parts must be enabled for the patch to work:

Part 1 (paste into libnickel.so.1.0.0.patch):
Spoiler:
Code:
<Patch>
patch_name = `Force user line spacing in ePubs (part 1 of 2)`
patch_enable = `no`
# Multi-version patch: 3.3.0 - 3.17.3+
#
# This is part 1 of 2. Also enable part 2 in librmsdk.so.1.0.0.patch
#
# This patch prevents any line-height style set in the book's stylesheet from
# being recognised. It will spoil the formatting of some books, but will ensure
# that the line spacing set with the adjustment slider always takes effect.
#
find_base_address = `\0\0\x20\0l\0i\0n\0e\0-\0h\0e\0i\0g\0h\0t\0`
replace_string = 0004, `l`, `_`
</Patch>


Part 2 (paste into librmsdk.so.1.0.0.patch):
Spoiler:
Code:
<Patch>
patch_name = `Force user line spacing in ePubs (Part 2 of 2)`
patch_enable = `no`
# Multi-version patch: 3.3.0 - 3.17.3+
#
# This is part 2 of 2. Also enable part 1 in libnickel.so.1.0.0.patch
#
# This patch prevents any line-height style set in the book's stylesheet from
# being recognised. It will spoil the formatting of some books, but will ensure
# that the line spacing set with the adjustment slider always takes effect.
#
find_base_address = `\0line-height\0`
replace_string = 0001, `l`, `_`
find_base_address = `\0font\0`
replace_string = 0001, `f`, `_`
</Patch>


This patch should also work with older firmware versions as far back as 3.3.0. If using it with versions 3.15.0 or earlier make sure part 1 appears in libnickel.so.1.0.0.patch after the `Unitless ePub line height` patch.

This patch is not compatible with the old `Enforce user line spacing in ePubs` patch. (That patch is not very effective in current firmware versions, I'll delete it in future versions unless someone still finds it useful.)

Edit: Note that the font style is a shorthand that sets other styles as well as line-height. It is not used in ePubs very much, but on those occasions where it is this patch will probably have much worse effects on the formatting than usual. If you want to allow the font style to be recognised, which could prevent the user line spacing working just on those uncommon ePubs which have this style, you can comment out the last two lines (find_base_address and replace_string) in part 2 of the patch.

Edit2: To those of you who use it: Is it best to block line-height and font by default, or should the patch just block line-height and leave the blocking of font as an option?

Last edited by GeoffR; 08-22-2015 at 12:58 PM. Reason: Option to comment out last two lines in part 2
GeoffR is offline   Reply With Quote