View Single Post
Old 01-18-2015, 11:12 PM   #130
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
`Fix kepub side bearing font cut-off bug` patch and new KoboTouchExtended driver.

Here is a new version of the `Fix kepub side bearing font cut-off bug` patch, it should work better with kepubs sideloaded with the new version of the KoboTouchExtended driver being tested here.
Spoiler:
Code:
<Patch>
patch_name = `Fix kepub side bearing font cut-off bug`
patch_enable = `yes`
#
# In kepubs, characters with large side bearing values (such as f) can be cut
# off if they appear at the very end of a line. The problem seems to be most
# noticable in full-screen mode. To fix it this patch adds one of the following
# lines to the built-in kepub stylesheet:
#
#  div#book-columns{padding-left:.2em!important;padding-right: .2em!important}
#  div#book-columns{padding-top: .2em!important;padding-bottom:.2em!important}
#  div#book-columns{padding:     .2em                          .2em!important}
#  body>*          {padding-left:.2em!important;padding-right: .2em!important}
#  body>*          {padding-top: .2em!important;padding-bottom:.2em!important}
#  body>*          {padding:     .2em                          .2em!important}
#
# There are two main types of kepub, each affected differently by this patch:
#
# Type 1: kepubs created by Kobo from epub2 books, or created by Calibre with
#         a new version of the KoboTouchExtended driver.
#
# Type 2: kepubs created by Kobo from epub3 books, or created by Calibre with
#         an old version of the KoboTouchExtended driver.
#
# Type 1 kepubs work best with this patch, the only side effects should be
# slightly larger screen margins. Some Type 2 kepubs might suffer additional
# side effects such as extra horizontal or vertical space between elements.
# There is an option below (marked **1**) where you can choose whether to
# fix the bug only for Type 1 kepubs (default) or for both types.
#
# There are also options below (marked **2**) to make the patch suit kepubs
# with horizontal or vertical text directions, or both. The side effects for
# Type 2 kepubs will likely be worse if the option for both horizontal and
# vertical is chosen.
#
#
replace_string = DB4470, `.\x00K\x00B\x00H\x00i\x00g\x00h\x00l\x00i\x00g\x00h\x00t\x00i\x00n\x00g\x00 \x00{\x00 \x00b\x00a\x00c\x00k\x00g\x00r\x00o\x00u\x00n\x00d\x00-\x00c\x00o\x00l\x00o\x00r\x00:\x00 \x00#\x00C\x006\x00C\x006\x00C\x006\x00 \x00!\x00i\x00m\x00p\x00o\x00r\x00t\x00a\x00n\x00t\x00;\x00 \x00}\x00 \x00\t\x00`, `.\x00K\x00B\x00H\x00i\x00g\x00h\x00l\x00i\x00g\x00h\x00t\x00i\x00n\x00g\x00{\x00b\x00a\x00c\x00k\x00g\x00r\x00o\x00u\x00n\x00d\x00-\x00c\x00o\x00l\x00o\x00r\x00:\x00#\x00C\x006\x00C\x006\x00C\x006\x00!\x00i\x00m\x00p\x00o\x00r\x00t\x00a\x00n\x00t\x00}\x00.\x00K\x00B\x00S\x00t\x00a\x00c\x00k\x00`
#
replace_string = DB44E6, `.\x00K\x00B\x00S\x00t\x00a\x00c\x00k\x00K\x00e\x00y\x00w\x00o\x00r\x00d\x00,\x00 \x00.\x00K\x00B\x00S\x00e\x00a\x00r\x00c\x00h\x00R\x00e\x00s\x00u\x00l\x00t\x00,\x00 \x00.\x00K\x00B\x00A\x00n\x00n\x00o\x00t\x00a\x00t\x00i\x00o\x00n\x00,\x00 \x00.\x00K\x00B\x00H\x00i\x00g\x00h\x00l\x00i\x00g\x00h\x00t\x00i\x00n\x00g\x00 \x00,\x00 \x00K\x00B\x00A\x00u\x00t\x00h\x00o\x00r\x00A\x00n\x00n\x00o\x00t\x00a\x00t\x00i\x00o\x00n\x00{\x00 \x00f\x00o\x00n\x00t\x00-\x00s\x00i\x00z\x00e\x00:\x00 \x001\x000\x000\x00%\x00 \x00!\x00i\x00m\x00p\x00o\x00r\x00t\x00a\x00n\x00t\x00;\x00 \x00-\x00w\x00e\x00b\x00k\x00i\x00t\x00-\x00t\x00e\x00x\x00t\x00-\x00c\x00o\x00m\x00b\x00i\x00n\x00e\x00:\x00 \x00i\x00n\x00h\x00e\x00r\x00i\x00t\x00 \x00!\x00i\x00m\x00p\x00o\x00r\x00t\x00a\x00n\x00t\x00;\x00 \x00}\x00 \x00\t\x00`, `K\x00e\x00y\x00w\x00o\x00r\x00d\x00,\x00.\x00K\x00B\x00S\x00e\x00a\x00r\x00c\x00h\x00R\x00e\x00s\x00u\x00l\x00t\x00,\x00.\x00K\x00B\x00A\x00n\x00n\x00o\x00t\x00a\x00t\x00i\x00o\x00n\x00,\x00.\x00K\x00B\x00H\x00i\x00g\x00h\x00l\x00i\x00g\x00h\x00t\x00i\x00n\x00g\x00,\x00 \x00K\x00B\x00A\x00u\x00t\x00h\x00o\x00r\x00A\x00n\x00n\x00o\x00t\x00a\x00t\x00i\x00o\x00n\x00{\x00f\x00o\x00n\x00t\x00-\x00s\x00i\x00z\x00e\x00:\x001\x000\x000\x00%\x00!\x00i\x00m\x00p\x00o\x00r\x00t\x00a\x00n\x00t\x00;\x00-\x00w\x00e\x00b\x00k\x00i\x00t\x00-\x00t\x00e\x00x\x00t\x00-\x00c\x00o\x00m\x00b\x00i\x00n\x00e\x00:\x00i\x00n\x00h\x00e\x00r\x00i\x00t\x00!\x00i\x00m\x00p\x00o\x00r\x00t\x00a\x00n\x00t\x00}\x00.\x00K\x00B\x00S\x00e\x00a\x00r\x00c\x00h\x00R\x00e\x00s\x00u\x00l\x00t\x00{\x00b\x00a\x00c\x00k\x00g\x00r\x00`
#
replace_string = DB4626, `.\x00K\x00B\x00S\x00e\x00a\x00r\x00c\x00h\x00R\x00e\x00s\x00u\x00l\x00t\x00 \x00{\x00 \x00b\x00a\x00c\x00k\x00g\x00r\x00o\x00u\x00n\x00d\x00-\x00c\x00o\x00l\x00o\x00r\x00:\x00 \x00#\x00C\x006\x00C\x006\x00C\x006\x00 \x00!\x00i\x00m\x00p\x00o\x00r\x00t\x00a\x00n\x00t\x00;\x00 \x00}\x00 \x00\t\x00`, `o\x00u\x00n\x00d\x00-\x00c\x00o\x00l\x00o\x00r\x00:\x00#\x00C\x006\x00C\x006\x00C\x006\x00!\x00i\x00m\x00p\x00o\x00r\x00t\x00a\x00n\x00t\x00}\x00.\x00K\x00B\x00S\x00t\x00a\x00c\x00k\x00K\x00e\x00y\x00w\x00o\x00r\x00d\x00 \x00a\x00{\x00c\x00o\x00l\x00o\x00r\x00:\x00b\x00l\x00a\x00c\x00k\x00!\x00`
#
replace_string = DB469C, `.\x00K\x00B\x00S\x00t\x00a\x00c\x00k\x00K\x00e\x00y\x00w\x00o\x00r\x00d\x00 \x00a\x00 \x00{\x00 \x00c\x00o\x00l\x00o\x00r\x00:\x00 \x00b\x00l\x00a\x00c\x00k\x00 \x00!\x00i\x00m\x00p\x00o\x00r\x00t\x00a\x00n\x00t\x00;\x00 \x00}\x00 \x00\t\x00`, `i\x00m\x00p\x00o\x00r\x00t\x00a\x00n\x00t\x00}\x00.\x00K\x00B\x00A\x00u\x00t\x00h\x00o\x00r\x00A\x00n\x00n\x00o\x00t\x00a\x00t\x00i\x00o\x00n\x00,\x00.\x00K\x00B\x00A\x00u\x00t\x00h\x00o\x00r\x00A\x00n\x00n\x00o\x00t\x00a\x00t\x00i\x00o\x00`
#
replace_string = DB46FC, `.\x00K\x00B\x00A\x00u\x00t\x00h\x00o\x00r\x00A\x00n\x00n\x00o\x00t\x00a\x00t\x00i\x00o\x00n\x00,\x00 \x00.\x00K\x00B\x00A\x00u\x00t\x00h\x00o\x00r\x00A\x00n\x00n\x00o\x00t\x00a\x00t\x00i\x00o\x00n\x00C\x00o\x00n\x00t\x00i\x00n\x00u\x00e\x00d\x00 \x00{\x00 \x00b\x00a\x00c\x00k\x00g\x00r\x00o\x00u\x00n\x00d\x00-\x00c\x00o\x00l\x00o\x00r\x00:\x00 \x00t\x00r\x00a\x00n\x00s\x00p\x00a\x00r\x00e\x00n\x00t\x00 \x00!\x00i\x00m\x00p\x00o\x00r\x00t\x00a\x00n\x00t\x00;\x00 \x00t\x00e\x00x\x00t\x00-\x00d\x00e\x00c\x00o\x00r\x00a\x00t\x00i\x00o\x00n\x00:\x00 \x00n\x00o\x00n\x00e\x00 \x00!\x00i\x00m\x00p\x00o\x00r\x00t\x00a\x00n\x00t\x00;\x00 \x00}\x00 \x00\t\x00`, `n\x00C\x00o\x00n\x00t\x00i\x00n\x00u\x00e\x00d\x00{\x00b\x00a\x00c\x00k\x00g\x00r\x00o\x00u\x00n\x00d\x00-\x00c\x00o\x00l\x00o\x00r\x00:\x00t\x00r\x00a\x00n\x00s\x00p\x00a\x00r\x00e\x00n\x00t\x00!\x00i\x00m\x00p\x00o\x00r\x00t\x00a\x00n\x00t\x00;\x00t\x00e\x00x\x00t\x00-\x00d\x00e\x00c\x00o\x00r\x00a\x00t\x00i\x00o\x00n\x00:\x00n\x00o\x00n\x00e\x00!\x00i\x00m\x00p\x00o\x00r\x00t\x00a\x00n\x00t\x00}\x00.\x00K\x00B\x00S\x00t\x00a\x00c\x00k\x00K\x00e\x00y\x00w\x00o\x00r\x00d\x00[\x00w\x00r\x00i\x00t\x00i\x00n\x00g\x00M\x00o\x00d\x00e\x00=\x00"\x00h\x00o\x00r\x00i\x00z\x00o\x00n\x00t\x00a\x00l\x00-\x00t\x00b\x00"\x00]\x00 \x00a\x00{\x00b\x00o\x00r\x00`
#
replace_string = DB4802, `.\x00K\x00B\x00S\x00t\x00a\x00c\x00k\x00K\x00e\x00y\x00w\x00o\x00r\x00d\x00[\x00w\x00r\x00i\x00t\x00i\x00n\x00g\x00M\x00o\x00d\x00e\x00=\x00"\x00h\x00o\x00r\x00i\x00z\x00o\x00n\x00t\x00a\x00l\x00-\x00t\x00b\x00"\x00]\x00 \x00a\x00 \x00{\x00 \x00b\x00o\x00r\x00d\x00e\x00r\x00-\x00b\x00o\x00t\x00t\x00o\x00m\x00:\x00 \x001\x00p\x00x\x00 \x00s\x00o\x00l\x00i\x00d\x00 \x00b\x00l\x00a\x00c\x00k\x00 \x00!\x00i\x00m\x00p\x00o\x00r\x00t\x00a\x00n\x00t\x00;\x00 \x00}\x00 \x00\t\x00`, `d\x00e\x00r\x00-\x00b\x00o\x00t\x00t\x00o\x00m\x00:\x001\x00p\x00x\x00 \x00s\x00o\x00l\x00i\x00d\x00 \x00b\x00l\x00a\x00c\x00k\x00!\x00i\x00m\x00p\x00o\x00r\x00t\x00a\x00n\x00t\x00}\x00.\x00K\x00B\x00A\x00u\x00t\x00h\x00o\x00r\x00A\x00n\x00n\x00o\x00t\x00a\x00t\x00i\x00o\x00n\x00[\x00w\x00r\x00i\x00t\x00i\x00n\x00g\x00M\x00o\x00d\x00e\x00=\x00"\x00h\x00o\x00r\x00i\x00z\x00o\x00n\x00t\x00a\x00l\x00-\x00t\x00b\x00"\x00]\x00,\x00.\x00K\x00B\x00A\x00u\x00t\x00h\x00o\x00r\x00`
#
replace_string = DB48C0, `.\x00K\x00B\x00A\x00u\x00t\x00h\x00o\x00r\x00A\x00n\x00n\x00o\x00t\x00a\x00t\x00i\x00o\x00n\x00[\x00w\x00r\x00i\x00t\x00i\x00n\x00g\x00M\x00o\x00d\x00e\x00=\x00"\x00h\x00o\x00r\x00i\x00z\x00o\x00n\x00t\x00a\x00l\x00-\x00t\x00b\x00"\x00]\x00,\x00 \x00.\x00K\x00B\x00A\x00u\x00t\x00h\x00o\x00r\x00A\x00n\x00n\x00o\x00t\x00a\x00t\x00i\x00o\x00n\x00C\x00o\x00n\x00t\x00i\x00n\x00u\x00e\x00d\x00[\x00w\x00r\x00i\x00t\x00i\x00n\x00g\x00M\x00o\x00d\x00e\x00=\x00"\x00h\x00o\x00r\x00i\x00z\x00o\x00n\x00t\x00a\x00l\x00-\x00t\x00b\x00"\x00]\x00 \x00{\x00 \x00b\x00o\x00r\x00d\x00e\x00r\x00-\x00b\x00o\x00t\x00t\x00o\x00m\x00:\x00 \x002\x00p\x00x\x00 \x00d\x00o\x00t\x00t\x00e\x00d\x00 \x00b\x00l\x00a\x00c\x00k\x00 \x00!\x00i\x00m\x00p\x00o\x00r\x00t\x00a\x00n\x00t\x00;\x00 \x00}\x00 \x00\t\x00`, `A\x00n\x00n\x00o\x00t\x00a\x00t\x00i\x00o\x00n\x00C\x00o\x00n\x00t\x00i\x00n\x00u\x00e\x00d\x00[\x00w\x00r\x00i\x00t\x00i\x00n\x00g\x00M\x00o\x00d\x00e\x00=\x00"\x00h\x00o\x00r\x00i\x00z\x00o\x00n\x00t\x00a\x00l\x00-\x00t\x00b\x00"\x00]\x00{\x00b\x00o\x00r\x00d\x00e\x00r\x00-\x00b\x00o\x00t\x00t\x00o\x00m\x00:\x002\x00p\x00x\x00 \x00d\x00o\x00t\x00t\x00e\x00d\x00 \x00b\x00l\x00a\x00c\x00k\x00!\x00i\x00m\x00p\x00o\x00r\x00t\x00a\x00n\x00t\x00}\x00.\x00K\x00B\x00A\x00n\x00n\x00o\x00t\x00a\x00t\x00i\x00o\x00n\x00[\x00w\x00r\x00i\x00t\x00i\x00n\x00g\x00M\x00o\x00d\x00e\x00=\x00"\x00h\x00o\x00r\x00i\x00z\x00o\x00n\x00t\x00a\x00l\x00-\x00t\x00b\x00"\x00]\x00,\x00.\x00K\x00B\x00A\x00n\x00n\x00o\x00t\x00a\x00t\x00i\x00o\x00n\x00C\x00o\x00n\x00t\x00i\x00n\x00u\x00e\x00d\x00[\x00w\x00`
#
replace_string = DB49FA, `.\x00K\x00B\x00A\x00n\x00n\x00o\x00t\x00a\x00t\x00i\x00o\x00n\x00[\x00w\x00r\x00i\x00t\x00i\x00n\x00g\x00M\x00o\x00d\x00e\x00=\x00"\x00h\x00o\x00r\x00i\x00z\x00o\x00n\x00t\x00a\x00l\x00-\x00t\x00b\x00"\x00]\x00,\x00 \x00.\x00K\x00B\x00A\x00n\x00n\x00o\x00t\x00a\x00t\x00i\x00o\x00n\x00C\x00o\x00n\x00t\x00i\x00n\x00u\x00e\x00d\x00[\x00w\x00r\x00i\x00t\x00i\x00n\x00g\x00M\x00o\x00d\x00e\x00=\x00"\x00h\x00o\x00r\x00i\x00z\x00o\x00n\x00t\x00a\x00l\x00-\x00t\x00b\x00"\x00]\x00 \x00{\x00 \x00b\x00o\x00r\x00d\x00e\x00r\x00-\x00b\x00o\x00t\x00t\x00o\x00m\x00:\x00 \x002\x00p\x00x\x00 \x00s\x00o\x00l\x00i\x00d\x00 \x00b\x00l\x00a\x00c\x00k\x00 \x00!\x00i\x00m\x00p\x00o\x00r\x00t\x00a\x00n\x00t\x00;\x00 \x00}\x00 \x00\t\x00`, `r\x00i\x00t\x00i\x00n\x00g\x00M\x00o\x00d\x00e\x00=\x00"\x00h\x00o\x00r\x00i\x00z\x00o\x00n\x00t\x00a\x00l\x00-\x00t\x00b\x00"\x00]\x00{\x00b\x00o\x00r\x00d\x00e\x00r\x00-\x00b\x00o\x00t\x00t\x00o\x00m\x00:\x002\x00p\x00x\x00 \x00s\x00o\x00l\x00i\x00d\x00 \x00b\x00l\x00a\x00c\x00k\x00!\x00i\x00m\x00p\x00o\x00r\x00t\x00a\x00n\x00t\x00}\x00d\x00i\x00v\x00#\x00b\x00o\x00o\x00k\x00-\x00c\x00o\x00l\x00u\x00m\x00n\x00s\x00{\x00p\x00a\x00d\x00d\x00i\x00n\x00g\x00-\x00l\x00e\x00f\x00t\x00:\x00.\x002\x00e\x00m\x00!\x00i\x00m\x00p\x00o\x00r\x00t\x00a\x00n\x00t\x00;\x00p\x00a\x00d\x00d\x00i\x00n\x00g\x00-\x00r\x00i\x00g\x00h\x00t\x00:\x00 \x00.\x002\x00e\x00m\x00!\x00i\x00m\x00p\x00o\x00r\x00t\x00a\x00n\x00t\x00}\x00\t\x00`
#
# Fix typo in annotations styles: KBAuthorAnnotation --> .KBAuthorAnnotation
replace_string = DB4552, `\x20`, `.`
#
# Choose padding size: 1 = 0.1em, 2 = 0.2em, etc.
replace_string = DB4AC0, `2`, `2`
replace_string = DB4AFC, `2`, `2`
#
#
# **1** Choose to fix bug for Type1 kepubs only, or both Type1 and Type2 kepubs.
# Default fixes the bug for Type 1 kepubs and has no effect on type 2 kepubs.
#
# Uncomment the following replace_string line to fix the bug for both types,
# but beware there can be undesirable side effects for some Type 2 kepubs:
#replace_string = DB4A82, `d\x00i\x00v\x00#\x00b\x00o\x00o\x00k\x00-\x00c\x00o\x00l\x00u\x00m\x00n\x00s\x00`, `b\x00o\x00d\x00y\x00>\x00*\x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00`
#
#
# **2** Choose padding location to suit text direction of your kepubs.
# Default is left/right padding (suits horizontal text directions only.)
#
# Either uncomment the following two replace_string lines for top/bottom
# padding (suits vertical text directions only) ...
#replace_string = DB4AB4, `l\x00e\x00f\x00t\x00:\x00`, `t\x00o\x00p\x00:\x00 \x00`
#replace_string = DB4AEC, `r\x00i\x00g\x00h\x00t\x00:\x00 \x00`, `b\x00o\x00t\x00t\x00o\x00m\x00:\x00`
#
# ... or else uncomment the following two replace_string lines for top/bottom
# and left/right padding (suits both horizontal and vertical text directions,
# but may have some undesirable side effects on the layout of Type 2 kepubs,
# such as extra spece between paragraphs.)
#replace_string = DB4AB2, `-\x00l\x00e\x00f\x00t\x00:\x00`, `:\x00 \x00 \x00 \x00 \x00 \x00`
#replace_string = DB4AC6, `!\x00i\x00m\x00p\x00o\x00r\x00t\x00a\x00n\x00t\x00;\x00p\x00a\x00d\x00d\x00i\x00n\x00g\x00-\x00r\x00i\x00g\x00h\x00t\x00:\x00`, `\x20\x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00`
#
</Patch>


I'll try to explain how it all works here, if this is not clear then let me know and I'll try to explain it better.

Some kepubs (I'll call them Type 1) have added book-columns and book-inner divisions, and these can be used to fix the cut-off bug suffered by kepubs in full-screen mode with a minimum of side effects, just slightly more space at the edge of the screen.

Other kepubs (I'll call them Type 2) don't have those divisions, and fixing the bug for these kepubs can sometimes result in extra space between elements of their layout, such as between floating elements like drop-caps, or in some cases between paragraphs.

Type 1 kepubs are the ones created by Kobo from epub2 books, and now created by the new KoboTouchExtended driver. (You can tell whether Kobo have created the kepub from an epub2 book because there will be an epub2 download option on the website.)

Type 2 kepubs are the ones created by Kobo from epub3 books, and by the old KoboTouchExtended driver.


If you only read sideloaded kepubs created by the new KoboTouchExtended driver, then you can fix the cut-off bug without using the firmware patch at all, by adding using the KoboTouch driver's "Extra CSS" option and adding the following line to your kobo_extra.css:
Code:
div#book-columns {padding: 0.2em !important;}

If you read kepubs synced from Kobo, or created by the old KoboTouchExtended driver, then you'll need to use the firmware patch to fix the bug. You can use the firmware patch with kepubs created by the new KoboTouchExtended driver too, in which case it is not necessary to use the "Extra CSS" option described above. If you use both the firmware patch and kobo_extra.css then the patch will override kobo_extra.css

The patch has two main options, marked **1** and **2**. See the notes in the patch itself about these options. You'll need to change option **1** if you want to fix the bug for type 2 kepubs.

Last edited by GeoffR; 01-24-2015 at 05:25 AM. Reason: replaced `Fix kepub side bearing font cut-off bug` patch with one that works with patch32lsb v0.7
GeoffR is offline   Reply With Quote