04-22-2014, 05:50 AM | #1 |
Wizard
Posts: 3,821
Karma: 19162882
Join Date: Nov 2012
Location: Te Riu-a-Māui
Device: Kobo Glo
|
Adjustable top/bottom margin patch testing
Here is a patch to make the top and/or bottom margins adjustable in epubs. I.e. when you use the slider to adjust the left/right margins, the top/bottom margins change too. Please treat this as experimental for now, I have tested it a little on my Glo and it seems to work without problems, but I am still learning ARM assembly and I might have overlooked something, so more testing and feedback would be good.
The patch works by modifying the epub reader's built-in stylesheet. The original stylesheet looks like this: Code:
@font-face { font-family: -ua-default; font-style: normal; font-weight: normal; src: url('res:///fonts/normal/%1') } @font-face { font-family: -ua-default; font-style: italic; font-weight: normal; src: url('res:///fonts/italic/%1') } @font-face { font-family: -ua-default; font-style: italic; font-weight: bold; src: url('res:///fonts/bolditalic/%1') } @font-face { font-family: -ua-default; font-style: normal; font-weight: bold; src: url('res:///fonts/bold/%1') } body, p { font-family: -ua-default !important; } body { text-align: %1 !important; line-height: %1em !important; padding-bottom: %1em !important; -kobo-font-sharpness: %1; -kobo-font-thickness: %1; } (One side effect of this is that the epub reader no longer adds any padding at the end of a chapter, I don't know if this is important or not?) (Edit: Another side effect seems to be that any @page margins set in the epub itself will not take effect) You can change how much the top/bottom margins increase by editing the replacement string in the patch. I have used units of pt which seems about right on my Glo, but feedback about how it suits other devices would be useful. This patch should work okay on its own, but it is probably better in combination with the custom margins and footer patches. If you choose to make the bottom margin adjustable, then you will probably want to modify your footer so that there is not too much margin between the top of the page number and the bottom of the text. Hopefully we can find good combinations of footer and bottom margin size to look good on the different devices. Patch for firmware 3.2.0 (kpg.exe version, yes I have tested it with kpg.exe ths time :-) Spoiler:
Patch for firmware 3.2.0 (patch32lsb.conf version): Spoiler:
Edit: Here is the patches for firmware 3.3.0. The adjustable margins work with the new full-screen reading mode too. Unfortunately the way the stylesheet is stored makes it difficult to edit the replacement strings in the patch, be careful not to change the length of the replacement strings if you do attempt to edit them. Patch for firmware 3.3.0 (kpg.conf version) Spoiler:
Patch for firmware 3.3.0 (patch32lsb.conf version) Spoiler:
Last edited by GeoffR; 04-28-2014 at 06:16 PM. Reason: Updated patches for firmware version 3.3.0 |
04-22-2014, 08:51 AM | #2 |
Wizard
Posts: 3,821
Karma: 19162882
Join Date: Nov 2012
Location: Te Riu-a-Māui
Device: Kobo Glo
|
Here are some screenshots of an epub on my Glo with the margin slider at three different positions (0, 4, 7). The adjustable margin patch is applied with the top and bottom and 2x scale options, units in pt, and the footer patch is applied with min/max-height: 30px, padding-bottom: 25px.
(obviously the bottom margin will still vary depending on font size, line spacing etc.) |
04-22-2014, 10:40 PM | #3 | |
Grand Sorcerer
Posts: 6,212
Karma: 16534894
Join Date: Sep 2009
Location: UK
Device: Kobo: KA1, ClaraHD, Forma, Libra2, Clara2E. PocketBook: TouchHD3
|
Quote:
It's too late for me to try this until tomorrow, however, I think it's possible that this 'no padding side effect' may also solve the long-standing 'end-of-chapter bug' (the one a bit like the 'long paragraph bug'). |
|
04-25-2014, 01:15 AM | #4 |
Wizard
Posts: 3,821
Karma: 19162882
Join Date: Nov 2012
Location: Te Riu-a-Māui
Device: Kobo Glo
|
Unfortunately not though, I find the end-of-chapter bug is still present in firmware 3.3.0, with or without this patch.
|
04-25-2014, 01:11 PM | #5 |
Grand Sorcerer
Posts: 6,212
Karma: 16534894
Join Date: Sep 2009
Location: UK
Device: Kobo: KA1, ClaraHD, Forma, Libra2, Clara2E. PocketBook: TouchHD3
|
My comment was based on an entirely coincidental experimental patch I've been trying for the last week. Following your 'unitless line height' patch I thought I'd try something similar by applying a simple Patch to change
Code:
padding-bottom: %1em !important; Code:
padding-bottom: 0 !important; It's quite difficult to be absolutely sure, especially because my own standard styling includes a small non-zero margin-top (0.25em) on standard paragraphs, so I don't expect to see the same number of lines on every page. My gut-feel is that sometimes it has helped to get the last line of some chapters fitted onto the bottom of a page rather than starting a new page for the last few words. Of course, some chapters do still end on the first line of a new page but again, my gut-feel is that they wouldn't have fitted on the previous page with the existing font-size/line-spacing settings. I am sure that my testing could have been more scientific but I'm inclined to stick to reading books with my preferred styling for now and just 'suck it and see' for a while It's been a harmless patch so far, but as I never use padding settings in my standard css it's hard to say whether others who do use it would see some unwanted side-effect. |
04-27-2014, 04:09 AM | #6 |
Enthusiast
Posts: 46
Karma: 66500
Join Date: Jan 2011
Device: kobo glo
|
I notice that if this patch is activated that line spacing don't match to my ebook config when i open a new ebook. i use 0.92 spacing and when i open a ebook sometimes the line are close. I change a parameter and always is fine.
Last edited by sage79; 04-27-2014 at 06:08 AM. |
04-27-2014, 06:05 PM | #7 | |
Wizard
Posts: 3,821
Karma: 19162882
Join Date: Nov 2012
Location: Te Riu-a-Māui
Device: Kobo Glo
|
Quote:
I have seen something similar just with the ordinary `My line spacing values` patch, but only when opening a book that I had previously opened before patching. I think it has something to do with the line spacing value that was previously set in the book no longer matching any of the values on the slider after patching (e.g. if the book had been set to 1.07 with the unpatched firmware, but 1.07 is not one of the values that I have on my slider after patching). |
|
04-28-2014, 06:26 PM | #8 |
Wizard
Posts: 3,821
Karma: 19162882
Join Date: Nov 2012
Location: Te Riu-a-Māui
Device: Kobo Glo
|
I've updated the patches for firmware 3.3.0, the scale for the top/bottom margins can now be set to any number of pixels by changing the replace_int line.
I have found a value of 5px looks good on my Glo, closely matching the size of the left/right margins. Based on the different resolution screens I assume that a value of 4px would suit the Touch/Mini and 7px for the Aura HD. |
04-29-2014, 02:28 AM | #9 | |
Connoisseur
Posts: 62
Karma: 13112
Join Date: Feb 2013
Device: Kindle Paperwhite; KOBO AURA HD
|
Quote:
|
|
04-29-2014, 02:34 AM | #10 | |
Wizard
Posts: 3,821
Karma: 19162882
Join Date: Nov 2012
Location: Te Riu-a-Māui
Device: Kobo Glo
|
Quote:
|
|
04-29-2014, 02:51 AM | #11 | |
Connoisseur
Posts: 62
Karma: 13112
Join Date: Feb 2013
Device: Kindle Paperwhite; KOBO AURA HD
|
Quote:
If I use the patch32lsb and it reports error. Does this patcher work on Windows 7 64bit? error information: C:\Users\xxx\Desktop\patch_kobo_330\tools\pa32lsb. exe: line 227 in 'C:\Users\ xxx\Desktop\patch_kobo_330\3.3.0_source\libnickel. so.1.0.0.patch': replace_xo r not implemented, use encode_xor8 + replace_string instead. ERROR processing C:\Users\xxx\Desktop\patch_kobo_330\3.3.0_source\l ibnickel.s o.1.0.0.patch Press any key to continue . . . |
|
04-29-2014, 03:12 AM | #12 | |
Connoisseur
Posts: 62
Karma: 13112
Join Date: Feb 2013
Device: Kindle Paperwhite; KOBO AURA HD
|
Quote:
Thanks. |
|
05-01-2014, 09:38 PM | #13 |
Wizard
Posts: 3,821
Karma: 19162882
Join Date: Nov 2012
Location: Te Riu-a-Māui
Device: Kobo Glo
|
I've included this patch with the other patches in the instructions for patching 3.3.x thread, but I've left it disabled by default. Although I have been using this patch without any problems on my Glo, and now wouldn't want to be without it, it might not be such a big deal to others :-)
|
05-15-2014, 06:09 AM | #14 |
Wizard
Posts: 3,821
Karma: 19162882
Join Date: Nov 2012
Location: Te Riu-a-Māui
Device: Kobo Glo
|
Getting the bottom margin to match the top margin when using this patch can take a bit of fiddling with the reading footer. With the example reading footer patch the space above the page number is probably too large, but if you reduce the max-height of the reading footer then the page number can get cut off if using fonts like Gothic which sit very low on the line compared to other fonts. A way around this is to add a negative margin-top to the reading footer.
Below is the reading footer patch I am currently using on my Glo with firmware 3.3.0 to get good results when reading epubs with the adjustable top/bottom margin patch. It looks not too bad with kepubs too, although the space above the page number is smaller than ideal in that case. I've added examples for the Touch and Aura HD too, based on the difference in screen dpi compared to the Glo: Firmware 3.3.0: Spoiler:
|
06-13-2014, 01:02 PM | #15 |
frumious Bandersnatch
Posts: 7,516
Karma: 18512745
Join Date: Jan 2008
Location: Spaniard in Sweden
Device: Cybook Orizon, Kobo Aura
|
Would it be possible to completely remove the body margin/padding (or make them 0)? I'd like to have simply:
@page { margin: %1 } without "!important". Hopefully, that will let me force zero margins in a cover page with @page { margin: 0 !important}. But I'm afraid this CSS will have lower priority than the one in the book... |
|
Similar Threads | ||||
Thread | Thread Starter | Forum | Replies | Last Post |
Margin bottom, top problem on tablet | zs55 | Reading and Management | 7 | 05-23-2013 06:20 AM |
ODT to EPUB: margin-top and -bottom in tables | beedaddy | Conversion | 0 | 05-25-2012 05:05 AM |
margin top, bottom, additive or not ? | cybmole | Conversion | 5 | 02-16-2011 12:33 PM |
anyway to change Kindle top/bottom margin? | cdpango | Kindle Developer's Corner | 2 | 11-28-2010 08:20 PM |
calibre ignore margin-top and margin-bottom | bender | Calibre | 2 | 12-11-2009 06:58 AM |