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 12-30-2016, 11:04 AM   #1
Havner
Junior Member
Havner began at the beginning.
 
Havner's Avatar
 
Posts: 3
Karma: 10
Join Date: Nov 2016
Device: Kobo Aura H2O
Replacing the default fonts

Hi,

I have an issue with the default fonts, some of them don't have polish characters builtin. Ironically, most/all serif fonts do, while sans-serif fonts don't (Avenir/Gill).

I don't want to sideload replacements because I need this for multi-font documents that do display a default serif/sans-serif/monospace fonts. For the EPUB renderer this isn't much of an issue, as we can binary patch librmsdk and force it to even use sideloaded fonts. I've managed to do this successfully (set my own sideloaded sans-serif and monospace fonts using res:///fonts/...).

The problem is KEPUB renderer that uses sans: Georgia and sans-serif: Avenir by default. The latter has no polish letters. It also doesn't have a default monospace font.

My questions:

1. Is it possible to patch libnickel.so to change KEPUB renderer's defaults for the serif/sans-serif and possibly add one for monospace? I had a quick look at the occurrences of those two font names in the binary but it's not as straightforward as in librmsdk.so. No mention of monospace either. Has someone managed to do so?

2. Is it possible to just replace the default .ttf files in /usr/local/Trolltech/QtEmbedded-4.6.2-arm/lib/fonts? I've tried doing that with 4 avenir.ttf files I extracted from Mac OSX, but it didn't work, avenir completely disappeared from the font menu and sans-serif became Georgia by default. Looking at the files in /usr/local/Trolltech/QtEmbedded-4.6.2-arm/lib/fonts I've found they are not actually TrueType fonts. No idea what format is that. file unix tool says: "Avenir.ttf: data". FontForge doesn't recognize them either. What format are they in? Are there replacement Avenir fonts with polish characters available somewhere?

As a sidenote: I know that I can do all of this by editing book's css file and embedding my own fonts. I've done that successfully, but what I would like is to have sane defaults for the kepub renderer itself.

Any ideas?
Havner is offline   Reply With Quote
Old 12-30-2016, 11:50 AM   #2
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,251
Karma: 16539642
Join Date: Sep 2009
Location: UK
Device: ClaraHD, Forma, Libra2, Clara2E, LibraCol, PBTouchHD3
Quote:
Originally Posted by Havner View Post
Any ideas?
I believe the Kobo built-in fonts are obfuscated so overwriting the .ttf files with your own versions is probably not an option.

I'm not sure how helpful the following will be for you, but I'll outline how I solved this problem for kepubs on my own devices.

With kepubs there's no need to add extra @font-face statements. Simply changing the internal CSS files so that any instances of the generic
Code:
font-family: sans-serif;
font-family: monospace;
are changed to:
Code:
font-family: "my sideloaded sans-serif font name";
font-family: "my sideloaded monospace font name";
will do the trick. How and where you make these changes is the problem to be solved.

In my case I added an extra feature to my forked version of the KoboTouchExtended plugin so that the internal CSS files are changed on-the-fly during the calibre send-to-device process. This allowed me to leave my calibre library master copies untouched and only make the CSS changes when the book is delivered to the Kobo as a kepub.

FWIW I use a similar technique to make sure font-variant:small-caps is converted to CSS code which will display a sideloaded true small-caps font for both kepubs and epubs, although the technique for each format is slightly different.

Maybe someone else can come up with a simpler idea which doesn't involve programming.
jackie_w is offline   Reply With Quote
Advert
Old 12-30-2016, 12:57 PM   #3
Havner
Junior Member
Havner began at the beginning.
 
Havner's Avatar
 
Posts: 3
Karma: 10
Join Date: Nov 2016
Device: Kobo Aura H2O
Quote:
Originally Posted by jackie_w View Post
I believe the Kobo built-in fonts are obfuscated so overwriting the .ttf files with your own versions is probably not an option.
Yeah, I just found a note on these forums that they are encrypted. Still, it doesn't mean there is no way to replace them, just that we cannot modify them.

Quote:
I'm not sure how helpful the following will be for you, but I'll outline how I solved this problem for kepubs on my own devices.
Like I said I know how to do this by modifying CSS files of the book. I'm looking for more of a "system" solution. Thanks anyway.

Quote:
With kepubs there's no need to add extra @font-face statements.
This is new to me though. I was able to point epubs to sideloaded fonts (with res:///fonts/), but for kepubs the only way I found was to actually embed the font in the book itself. Both cases required @font-face. I'll have a try. Thanks.

I also know how to do this automatically with Calibre and kobo_extra.css.

EDIT: reread your post, you're not modifying the default sans and sans-serif definitions, you're replacing their usage directly with a font name. Ok, that's why the @font-face is not required. To change the definitions to new fonts it is still required. Still, I get the final effect is the same for how the book looks.

Last edited by Havner; 12-30-2016 at 01:15 PM.
Havner is offline   Reply With Quote
Reply


Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
PRS-T3 Default line spacing and fonts? Amalthia Sony Reader 2 01-16-2014 01:58 PM
PRS-T1 replacing system default fonts ousia Sony Reader Dev Corner 0 11-06-2012 04:10 PM
How to add alternate fonts without replacing system fonts.(this time this is a guide) techiemonkey Kindle Developer's Corner 17 09-12-2012 04:55 PM
PRS-950 Replacing Default Font? anamardoll Sony Reader 9 06-06-2011 11:16 PM
change default fonts p3aul Sigil 3 10-18-2009 07:14 PM


All times are GMT -4. The time now is 05:34 AM.


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