View Single Post
Old 10-14-2016, 06:54 AM   #24
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
`ePub fixed/adjustable top/bottom margins`

I've updated the `ePub fixed/adjustable top/bottom margins` patch, but I haven't tested it.

Beware that this is the most complicated patch I have done, I don't always get it right first time, so if someone who has used it before could try it out and confirm that it works as expected that would be great. (If is is not working the most likely result will be that the device crashes as soon as an ePub book is opened.)

`ePub fixed/adjustable top/bottom margins` patch for firmware 4.1.7729 (post into libnickel.so.1.0.0.patch):
Spoiler:
Code:
#
# The following three patches are mutually incompatible,
# don't enable more than one.
#
# `ePub fixed/adjustable top/bottom margins`
# `ePub fixed top/bottom margins`
# `ePub disable built-in body padding-bottom`
#

<Patch>
patch_name = `ePub fixed/adjustable top/bottom margins`
patch_enable = `yes`
# patch_group = `ePub padding-bottom alternatives`
#
## This patch sets the @page margin sizes in epubs, overriding any @page margin
## set in the book's CSS stylesheet (but not in the XPGT stylesheet, see below).
##
## By default the top and bottom margins are set to be adjustable, their size
## similar to the left/right margin size set by the adjustment slider. There
## are options to set the top and/or bottom margin to a fixed size instead.
##
## Note that @page margins are seperate from (and overlap) both the body margins
## set in the book and the left/right margins set from the adjustment slider,
## and are added to any page margins set in the Adobe XPGT stylesheet if the
## book has one (e.g. page-template.xpgt). For this reason you might want to
## consider using the Modify ePub Calibre plugin to remove any body margins and
## XPGT stylesheet margins before sideloading the book, or perhaps enabling the
## `Ignore ePub Adobe XPGT stylesheet (page-template.xpgt)` patch.
##
## Also note that a side-effect of this patch is that the body padding-bottom is
## removed from the built-in stylesheet, which means that there will no longer
## be a blank line added automatically at the end of chapters.
##
## See at the bottom of the patch for replacement values that can be used to
## tune the size of the margins to suit different devices and reading modes.
#
#
# Push an extra 8 bytes of scratch space onto the stack
replace_bytes = 50BAB8, B7 B0, B9 B0
replace_bytes = 50BABC, 02 AF, 04 AF
# Save this value for the third stack argument of the following function call
replace_bytes = 50BD38, AD F8 04 30, 02 93 01 93
# getReadingLineHeight(...) --> getReadingLeftMargin(...) b8260c 4b4ecc
replace_bytes = 50BD6A, CD F7 A0 EE, A9 F7 B0 E8
#
replace_bytes = 50BD6E, 4F F0 FF 33 07 F1, 00 23 01 22 0A 21
replace_bytes = 50BD74, 3C 0A 00 93, 00 93 01 91
replace_bytes = 50BD78, 20 23 AD F8 04 30, 42 43 92 08 01 3A
replace_bytes = 50BD7E, 50 46 21 46, B8 BF 00 22
replace_bytes = 50BD82, 00 22 67 23, 13 A8 21 46
# QString.arg(double, ...) --> QString.arg(int64, ...) b8229c 4b43f4
replace_bytes = 50BD86, B6 F7 EA ED, A8 F7 36 EB
# mov r1,sl; --> adds r1,sp,#76
replace_bytes = 50BD8C, 51 46, 13 A9
# mov r0,sl; --> adds r0,sp,#76
replace_bytes = 50BD92, 50 46, 13 A8
# (Remember to pop scratch space if necessary)
#
#      padding-bottom: %1em !important;\n
# --> }@page{margin:%1px 00px %1px}body{
find_base_address = `\x20\0p\0a\0d\0d\0i\0n\0g\0-\0b\0o\0t\0t\0o\0m\0:\0 \0%\01\0e\0m\0 \0!\0i\0m\0p\0o\0r\0t\0a\0n\0t\0;\0\n\0`
replace_string = 0000, `\x20\0p\0a\0d\0d\0i\0n\0g\0-\0b\0o\0t\0t\0o\0m\0:\0 \0%\01\0e\0m\0 \0!\0i\0m\0p\0o\0r\0t\0a\0n\0t\0;\0\n\0`, `}\0@\0p\0a\0g\0e\0{\0m\0a\0r\0g\0i\0n\0:\0%\01\0p\0x\0 \00\00\0p\0x\0 \0%\01\0p\0x\0}\0b\0o\0d\0y\0{\0`
#
#
# *** Replacement values start here, don't change anything above ***
#
# Optional replacement value: Uncomment for a FIXED TOP MARGIN size in px,
# default 25px. Replacement value is margin size, two digits separated by \0
# (Leave commented out for an adjustable top margin.)
#replace_string = 001C, `%\01`, `2\05`
#
# Optional replacement value: Uncomment for a FIXED BOTTOM MARGIN size in px,
# default 00px. Replacement value is margin size, two digits separated by \0
# (Leave commented out for an adjustable bottom margin.)
#replace_string = 0030, `%\01`, `0\00`
#
# Optional replacement value: Uncomment to set the minimum LEFT/RIGHT MARGIN
# size in px, default 15px. (This margin will overlap the left/right margin
# set with the adjustment slider, not add to it.) Replacement value is margin
# size, two digits separated by \0
#replace_string = 0026, `0\00`, `1\05`
#
base_address = 000000
# Replacement value: Sets the step-size of the ADJUSTABLE top/bottom margin
# (if any) in quarter-pixels. These suggested values should be very close to
# the 1% step size of the left/right margins set by the slider. Larger values
# will make the top/bottom margins larger than the left/right margins.
# Suggested values:
#   24 (Touch/Mini), 30 (Glo/Aura/Aura2ed), 43 (AuraHD/H2O/GloHD), 56 (Aura One)
replace_int = 50BD70, 1, 30
#
# Replacement value: Set this to the size of the device's built-in top margin,
# in pixels. This value is subtracted from the adjustable top/bottom margin
# (if any) to compensate for any unremovable built-in top margin.
# Suggested values are:
#   0 For full-screen reading mode (fullScreenReading=true, all devices)
#  15 for normal reading mode (all devices)
replace_int = 50BD7C, 1, 0
</Patch>
GeoffR is offline   Reply With Quote