View Single Post
Old 02-19-2015, 01:39 AM   #27
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 zero body margin/padding` patch

This patch is a work-around for the problem where the text of some KePubs gets shifted to the right and cut off at the right margin in full-screen reading mode. It adds the following clause to the device's built-in KePub stylesheet:
Code:
body{margin:0!important;padding:0!important}
Spoiler:
Code:
<Patch>
patch_name = `KePub zero body margin/padding`
patch_enable = `yes`
# Multi-version patch: 3.12.0 - 3.13.1+
#
# This patch adds the following to the built-in KePub stylesheet:
#
#   body{margin:0!important;padding:0!important}
#
# which solves the problem with the text of some KePubs being shifted to the
# right and cut off at the right margin in full-screen reading mode.
#
find_base_address = `\t\0.\0K\0B\0S\0t\0a\0c\0k\0K\0e\0y\0w\0o\0r\0d\0[\0w\0r\0i\0t\0i\0n\0g\0M\0o\0d\0e\0=\0"\0v\0e\0r\0t\0i\0c\0a\0l\0-\0r\0l\0"\0]\0`
#
replace_string = 0000, `\t\0.\0K\0B\0S\0t\0a\0c\0k\0K\0e\0y\0w\0o\0r\0d\0[\0w\0r\0i\0t\0i\0n\0g\0M\0o\0d\0e\0=\0"\0v\0e\0r\0t\0i\0c\0a\0l\0-\0r\0l\0"\0]\0 \0a\0 \0{\0 \0b\0o\0r\0d\0e\0r\0-\0r\0i\0g\0h\0t\0:\0 \01\0p\0x\0 \0s\0o\0l\0i\0d\0 \0b\0l\0a\0c\0k\0 \0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0b\0l\0a\0c\0k\0 \0!\0i\0m\0p\0o\0r\0t\0a\0n\0t\0;\0 \0}\0 \0\t\0`, `r\0t\0i\0c\0a\0l\0-\0l\0r\0"\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[\0w\0r\0i\0t\0i\0n\0g\0M\0o\0d\0e\0=\0"\0v\0e\0r\0t\0i\0c\0a\0l\0-\0l\0r\0"\0]\0{\0b\0o\0r\0d\0e\0r\0-\0l\0e\0f\0t\0:\02\0p\0x\0 \0d\0o\0t\0t\0e\0d\0 \0b\0l\0a\0c\0k\0!\0i\0m\0p\0o\0r\0t\0a\0n\0t\0}\0b\0o\0d\0y\0{\0m\0a\0r\0g\0i\0n\0:\00\0!\0i\0m\0p\0o\0r\0t\0a\0n\0t\0;\0p\0a\0d\0d\0i\0n\0g\0:\00\0!\0i\0m\0p\0o\0r\0t\0a\0n\0t\0}\0`
#
# The body rule inserted above takes effect in normal reading mode too, which
# interferes with another rule used to set the user margins in normal reading
# mode. To prevent that happening, the following change is made to increase the
# priority of the user margin setting rule:
#
#     body { margin: 0px %1% 0px %2% ! important;}\n
# --> html body{margin:0px %1% 0px %2%!important;}\n
#
find_base_address = `b\0o\0d\0y\0 \0{\0 \0m\0a\0r\0g\0i\0n\0:\0 \00\0p\0x\0 \0%\01\0%\0`
#
replace_string = 0000, `b\0o\0d\0y\0 \0{\0 \0m\0a\0r\0g\0i\0n\0:\0 \00\0p\0x\0 \0%\01\0%\0 \00\0p\0x\0 \0%\02\0%\0 \0!\0 \0i\0`, `h\0t\0m\0l\0 \0b\0o\0d\0y\0{\0m\0a\0r\0g\0i\0n\0:\00\0p\0x\0 \0%\01\0%\0 \00\0p\0x\0 \0%\02\0%\0!\0i\0`
</Patch>


You may not need this patch if you only read sideloaded kepubs, as you can add the above line to the book's CSS instead, by using the kobo_extra.css feature of the KoboTouch driver in Calibre for example.

BEWARE that this patch prevents the margin adjustment slider working for KePubs in normal reading mode! So it is probably only useful to those who read Kobo-synced KePubs and always read them in full-screen mode. (It doesn't have any effect on ePubs in either reading mode.)

Edit: I have updated this patch, the new one no longer prevents kepub margin changes in normal reading mode.

If you use this patch, make sure to add it to libnickel.so.1.0.0.patch so that it comes after the `Fix kepub side bearing font cut-off bug` patch.

Attached are screenshots from my Glo showing a Kobo synced KePub affected by this problem (this one) in full-screen mode with and without this patch.
Attached Thumbnails
Click image for larger version

Name:	unpatched.png
Views:	675
Size:	59.0 KB
ID:	135014   Click image for larger version

Name:	patched.png
Views:	667
Size:	60.6 KB
ID:	135015  

Last edited by GeoffR; 02-23-2015 at 05:26 AM. Reason: Improved patch, no longer prevents kepub margin changes in normal reading mode.
GeoffR is offline   Reply With Quote