Register Guidelines E-Books Today's Posts Search

Go Back   MobileRead Forums > E-Book Readers > Kobo Reader > Kobo Developer's Corner

Notices

Reply
 
Thread Tools Search this Thread
Old 05-30-2019, 05:05 PM   #1
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 / KePub font sizes experiments

As per a PM conversation here are two patches which can be used to experiment with some settings relating to fonts sizes used in the ePub and KePub readers. I've posted them here in case others want to experiment and share results.

The patches won't do anything until you edit them and change the replacement values.

Firmware 4.15.12920, for libnickel.so.1.0.0.yaml:
Spoiler:
Code:
Set font scale factor:
  - Enabled: yes
  - Description: |
      This patch sets the font scale factor for ePub and KePub readers.
  # font scale factor is (current font size) / (X+32)
  # original value X=14, so (current font size) / 46 is original scale factor,
  # e.g. selecting font size 46 from the slider gives scale factor 1.0
  # allowed replacement values for X: 0-15 (smaller X --> larger scale factor)
  # ePub:
  - ReplaceInt: {Offset: 0x4A6EBA, Find: 14, Replace: 14}
  # KePub:
  - ReplaceInt: {Offset: 0xA2A5F0, Find: 14, Replace: 14}

Set Adobe units per inch:
  - Enabled: yes
  - Description: |
      This patch sets the value passed to AdobeStyling::setUnitsPerInch(int)
      which only affects the ePub reader.
  # original value is calculated as (scale factor) * X where:
  #   scale factor is as in the previous patch
  #   X = 144.0 for Dragon class devices, X = 96.0 for other devices
  # Other devices (Touch, Glo, etc.):
  - ReplaceBytes: {Offset: 0x4A70C0, FindH: 00 00 C0 42, ReplaceH: 00 00 C0 42}
  # Dragon class devices (AuraHD, H2O, etc.):
  - ReplaceBytes: {Offset: 0x4A70C4, FindH: 00 00 10 43, ReplaceH: 00 00 10 43}
  #
  # Sample replacement values:
  # X = 72.0:   ReplaceH: 00 00 90 42
  # X = 84.0:   ReplaceH: 00 00 A8 42
  # X = 96.0:   ReplaceH: 00 00 C0 42
  # X = 108.0:  ReplaceH: 00 00 D8 42
  # X = 120.0:  ReplaceH: 00 00 F0 42
  # X = 132.0:  ReplaceH: 00 00 04 43
  # X = 144.0:  ReplaceH: 00 00 10 43
  # X = 156.0:  ReplaceH: 00 00 1C 43
  # X = 168.0:  ReplaceH: 00 00 28 43


Edit: As an alternative to the second patch above, this one sets the ePub units per inch to a constant value of 300 instead of a multiple of the font scale factor.
Spoiler:
Code:
Constant Adobe units per inch:
  - Enabled: no
  - Description: | 
      This patch sets the value passed to AdobeStyling::setUnitsPerInch(int)
      as a constant instead of a multiple of the scale factor.
  - ReplaceBytes: {Offset: 0x4A6F02, FindH: 17 EE 90 1A, ReplaceH: 48 21 18 31}
  # Replacement value: units per inch = 72 + the replacement value
  # e.g. for 300 units per inch use replacement value 228
  - ReplaceInt: {Offset: 0x4A6F04, Find: 24, Replace: 228}

Last edited by GeoffR; 05-30-2019 at 05:42 PM.
GeoffR is offline   Reply With Quote
Old 05-30-2019, 08:22 PM   #2
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
I only have a Glo myself, and I fond the font size is usually the same in ePubs as in KePubs, but some have said that the font size is normally 50% larger in ePubs than in KePubs on some other devices.

The X value in the Set Adobe units per inch patch above is originally 144.0 for some devices and 96.0 for others, and 144 is 50% larger than 96, so that might account for it.

If that is the case then maybe Setting the X value to 96.0 for all devices would fix it? I.e. change the patch to:
Code:
Set Adobe units per inch:
  - Enabled: yes
  - Description: |
      This patch sets the value passed to AdobeStyling::setUnitsPerInch(int)
      which only affects the ePub reader.
  # original value is calculated as (scale factor) * X where:
  #   scale factor is as in the previous patch
  #   X = 144.0 for Dragon class devices, X = 96.0 for other devices
  # Other devices (Touch, Glo, etc.):
  - ReplaceBytes: {Offset: 0x4A70C0, FindH: 00 00 C0 42, ReplaceH: 00 00 C0 42}
  # Dragon class devices (AuraHD, H2O, etc.):
  - ReplaceBytes: {Offset: 0x4A70C4, FindH: 00 00 10 43, ReplaceH: 00 00 C0 42}
Edit: From what I can see, the KePub reader uses the same scale for all devices.

Last edited by GeoffR; 05-30-2019 at 11:20 PM.
GeoffR is offline   Reply With Quote
Advert
Old 05-31-2019, 05:30 PM   #3
jackie_w
Grand Sorcerer
jackie_w ought to be getting tired of karma fortunes by now.jackie_w ought to be getting tired of karma fortunes by now.jackie_w ought to be getting tired of karma fortunes by now.jackie_w ought to be getting tired of karma fortunes by now.jackie_w ought to be getting tired of karma fortunes by now.jackie_w ought to be getting tired of karma fortunes by now.jackie_w ought to be getting tired of karma fortunes by now.jackie_w ought to be getting tired of karma fortunes by now.jackie_w ought to be getting tired of karma fortunes by now.jackie_w ought to be getting tired of karma fortunes by now.jackie_w ought to be getting tired of karma fortunes by now.
 
Posts: 6,212
Karma: 16534894
Join Date: Sep 2009
Location: UK
Device: Kobo: KA1, ClaraHD, Forma, Libra2, Clara2E. PocketBook: TouchHD3
Hi Geoff,

Thank you for another good idea!

I've done some testing. I have to confess that post #1 bamboozled me so I put my effort into the patch in post #2.

Background:
My aim has only ever been to equalise font-sizes in epub/kepub.
Up to now I have been doing this via a kepub font scale-up in kobo_extra.css.
Code:
body>div#book-columns>div#book-inner {font-size:1.5em}
Of all the Kobos I own, this kepub scale-up was necessary on:
  • AuraHD
  • Aura6" (original)
  • H2O (original)
  • GloHD
  • ClaraHD
but not necessary on:
  • AuraOne
  • Forma
My Glo has been out of action for so long that I don't think I ever read any kepubs on it. Consequently I've no idea which of the above 2 groups it belongs in. I'll take your word that it's the second.

Test results:
I successfully used the post #2 patch on all of the above except the GloHD (it's off-limits because my husband is using it). I'd be amazed if its results were different from the ClaraHD.

Practicalities:
Nothing to do with the patch itself, but anyone who was using the kobo_extra.css trick and now wants to switch to this new patch is going to need to:
  • remove the kepub scale-up CSS from their kobo_extra.css file
  • delete all existing kepubs from their Kobo, then resend them
    I just deleted/resent ALL epubs and kepubs because any epubs with font settings stored in the database would now be wrong.

Other info:
  1. For any fw version, I only ever create a single patched KoboRoot.tgz file, then apply it to all my devices. Applying this patch to a KA1 or Forma (which don't need it) doesn't appear to do any harm - maybe it's too soon to state that categorically.
  2. I experimented with the post #2 patch to simplify it, removing the need for hex offsets, i.e. a multi-version patch.
    Code:
      - FindBaseAddressHex: 00 00 C0 42 00 00 10 43
      - ReplaceBytes: {Offset: 6, FindH: 10 43, ReplaceH: C0 42}
    This worked for fw 4.15.12920 on all devices. I also checked about 18 months-worth of libnickel.so.1.0.0 files (back as far as 4.6.xxxxx). The above FindBaseAddressHex string was unique in all of them. (Of course, Sod's Law says that it might not be in the next one )
jackie_w is offline   Reply With Quote
Old 06-02-2019, 07:15 PM   #4
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 uniform font scale patch

Thanks for the extensive testing jackie_w! (I can't figure out why the original Aura uses the larger font scale though.)

I'll add this patch, with a new name, to the current firmware patches. As noted it should work for versions 4.6.10075 and later:
ePub uniform font scale (paste into libnickel.so.1.0.0.yaml)
Spoiler:
Code:
ePub uniform font scale:
  - Enabled: yes
  - Description: |
      This patch makes the ePub reader use the same font scale on all devices,
      the same as the KePub reader does. Without this patch the ePub reader uses
      a 50% larger font size on AuraHD/H2O/GloHD/Clara (and Aura?) devices.
  - FindBaseAddressHex: 00 00 C0 42 00 00 10 43
  - ReplaceBytes: {Offset: 6, FindH: 10 43, ReplaceH: C0 42}


The same method of increasing the font scale by 50% for some devices seems to be used in all firmware versions at least as far back as 2.8.1, but the way the data is stored is slightly different for different versions, and it might well change again in future versions.

This is a version of the patch for firmware versions 2.8.1 - 3.19.5761:
`ePub uniform font scale: (paste into libnickel.so.1.0.0.patch)
Spoiler:
Code:
<Patch>
patch_name = `ePub uniform font scale:`
patch_enable = `yes`
# Multi-version patch: 2.8.1 - 3.19.5761
#
## This patch makes the ePub reader use the same font scale on all devices,
## the same as the KePub reader does. Without this patch the ePub reader uses
## a 50% larger font size on AuraHD/H2O/GloHD/Clara (and Aura?) devices.
#
find_base_address = `\x00\x00\x10\x43\x00\x00\xC0\x42`
replace_bytes = 0002, 10 43, C0 42
</Patch>


If anyone wants this patch for a firmware version from 4.0 to 4.5 just let me know.
GeoffR is offline   Reply With Quote
Old 06-08-2019, 05:46 AM   #5
mathil
Evangelist
mathil ought to be getting tired of karma fortunes by now.mathil ought to be getting tired of karma fortunes by now.mathil ought to be getting tired of karma fortunes by now.mathil ought to be getting tired of karma fortunes by now.mathil ought to be getting tired of karma fortunes by now.mathil ought to be getting tired of karma fortunes by now.mathil ought to be getting tired of karma fortunes by now.mathil ought to be getting tired of karma fortunes by now.mathil ought to be getting tired of karma fortunes by now.mathil ought to be getting tired of karma fortunes by now.mathil ought to be getting tired of karma fortunes by now.
 
Posts: 439
Karma: 287725
Join Date: Sep 2014
Location: Europe
Device: Kobo Aura H2O/Glo HD/Libra 2, Kindle PW3/PW5
I used the font scale patch on my Glo HD and I'm very pleased with it! I read kepub exclusively, and use only one font (Literata Book). This might sound weird, but my problem stems from the fact that I like reading at a very specific font size, that I wasn't able to find in all of my books (I assume that is because different publishers set different base font-sizes in the CSS files of their books, and the slider works from there). I tried changing the scale to 8 and that, in combination with the 'Custom font sizes' patch (that I was already using) seems to have done the trick. I am absolutely ignorant in the matter and this was probably a stroke of luck, but it seems to be working so far, so thanks GeoffR!
mathil is offline   Reply With Quote
Advert
Old 06-20-2019, 12:06 PM   #6
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
Quote:
Originally Posted by mathil View Post
I used the font scale patch on my Glo HD and I'm very pleased with it! I read kepub exclusively, and use only one font (Literata Book). This might sound weird, but my problem stems from the fact that I like reading at a very specific font size, that I wasn't able to find in all of my books (I assume that is because different publishers set different base font-sizes in the CSS files of their books, and the slider works from there). I tried changing the scale to 8 and that, in combination with the 'Custom font sizes' patch (that I was already using) seems to have done the trick. I am absolutely ignorant in the matter and this was probably a stroke of luck, but it seems to be working so far, so thanks GeoffR!
I've added the `Set font scale factor` patch to the current 4.15.12920 firmware patches, with your setting X=8 as the default.

I don't think it will be very useful to most people, but if someone want's it for an earlier firmware version then let me know.
GeoffR is offline   Reply With Quote
Old 08-28-2022, 07:01 AM   #7
Artemide
Enthusiast
Artemide began at the beginning.
 
Artemide's Avatar
 
Posts: 38
Karma: 10
Join Date: Aug 2022
Device: Kobo Libra 2, Pocketbook Basic Lux 3
Quote:
Originally Posted by GeoffR View Post
## This patch makes the ePub reader use the same font scale on all devices,
## the same as the KePub reader does. Without this patch the ePub reader uses
## a 50% larger font size on AuraHD/H2O/GloHD/Clara (and Aura?) devices.
#
find_base_address = `\x00\x00\x10\x43\x00\x00\xC0\x42`
replace_bytes = 0002, 10 43, C0 42
</Patch>
[/code][/spoiler]

If anyone wants this patch for a firmware version from 4.0 to 4.5 just let me know.
Hi Geoff, I'm new on this forum, but experienced with Linux, modding/root Android.
Is it possible to get this patch for last firmware 4.33.19759?
Unfortunately I get the problem of font size converting from epub to kepub and making a search for solve it, I found this thread.
I'm using a Kobo Libra 2 received some day ago, still haven't patched it because I wanna be sure that it works fine and it's not needed to return to the vendor.
Thank you in advance. I hope my english is clear.
Artemide is offline   Reply With Quote
Old 08-28-2022, 08:11 AM   #8
jackie_w
Grand Sorcerer
jackie_w ought to be getting tired of karma fortunes by now.jackie_w ought to be getting tired of karma fortunes by now.jackie_w ought to be getting tired of karma fortunes by now.jackie_w ought to be getting tired of karma fortunes by now.jackie_w ought to be getting tired of karma fortunes by now.jackie_w ought to be getting tired of karma fortunes by now.jackie_w ought to be getting tired of karma fortunes by now.jackie_w ought to be getting tired of karma fortunes by now.jackie_w ought to be getting tired of karma fortunes by now.jackie_w ought to be getting tired of karma fortunes by now.jackie_w ought to be getting tired of karma fortunes by now.
 
Posts: 6,212
Karma: 16534894
Join Date: Sep 2009
Location: UK
Device: Kobo: KA1, ClaraHD, Forma, Libra2, Clara2E. PocketBook: TouchHD3
Quote:
Originally Posted by Artemide View Post
Is it possible to get this patch for last firmware 4.33.19759?
Kobo font sizing has changed a lot since GeoffR last posted. This is the kobopatch thread for firmware 4.33.19759. All the instructions to get you started are in post #1.

The patch you're talking about is now called Unify font sizes and can be found in libnickel.so.1.0.0.yaml
jackie_w is offline   Reply With Quote
Old 08-28-2022, 12:22 PM   #9
Artemide
Enthusiast
Artemide began at the beginning.
 
Artemide's Avatar
 
Posts: 38
Karma: 10
Join Date: Aug 2022
Device: Kobo Libra 2, Pocketbook Basic Lux 3
Quote:
Originally Posted by jackie_w View Post
Kobo font sizing has changed a lot since GeoffR last posted. This is the kobopatch thread for firmware 4.33.19759. All the instructions to get you started are in post #1.

The patch you're talking about is now called Unify font sizes and can be found in libnickel.so.1.0.0.yaml
Many thanks for quick reply, I googled for search everything I need, so I jump directly to this thread.
Artemide is offline   Reply With Quote
Reply


Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
Font size difference between ePub & kepub JSWolf Kobo Reader 12 09-08-2020 11:03 AM
EPUB to AZW3: font sizes changed -- AGAIN! Phssthpok Conversion 17 12-24-2018 12:53 PM
EPUB to AZW3: font sizes changed Phssthpok Conversion 3 11-29-2018 11:42 AM
Smaller font size for kepub compared to epub on Kobo Aura HD yevgeny.bezman Kobo Reader 2 07-14-2015 12:16 PM
Aura HD Diferent font size in epub and kepub ersott Kobo Reader 24 04-15-2014 07:03 AM


All times are GMT -4. The time now is 03:26 AM.


MobileRead.com is a privately owned, operated and funded community.