Register Guidelines E-Books Today's Posts Search

Go Back   MobileRead Forums > E-Book Readers > Kobo Reader

Notices

Reply
 
Thread Tools Search this Thread
Old 03-25-2024, 08:03 AM   #1
repilo
Enthusiast
repilo began at the beginning.
 
Posts: 43
Karma: 10
Join Date: Apr 2021
Location: Spain
Device: Kobo Libra 2
Set a font in CSS so that it doesn't change from the Aa menu?

I have an epub that includes captions defined with sans-serif font. When I load it into the Kobo (transformed into kepub by Calibre), if I choose "Publisher default", the text looks in serif style (I've read that the default font is Georgia), and the captions look sans-serif, as defined.

However when I select any other font (I prefer serif) in the "Aa" menu of the Kobo, it is applied to all the text and also to the captions, even though they are defined as sans-serif.

I have tried embedding a sans-serif font (Aileron) and defining the captions with it, but the same thing still happens.


Is there any way to set a font (embedded or not) in an epub so that the ereader will use that one and not another one even though I select another font in the "Aa" menu?

I have found that I do not have this problem with the epub format, i.e. I can change the font in the "Aa" menu and the texts defined as sans-serif are still displayed in sans-serif. But I would prefer to have a solution for kepub.

Last edited by repilo; 03-25-2024 at 08:35 AM.
repilo is offline   Reply With Quote
Old 03-25-2024, 08:44 AM   #2
Sirtel
Grand Sorcerer
Sirtel ought to be getting tired of karma fortunes by now.Sirtel ought to be getting tired of karma fortunes by now.Sirtel ought to be getting tired of karma fortunes by now.Sirtel ought to be getting tired of karma fortunes by now.Sirtel ought to be getting tired of karma fortunes by now.Sirtel ought to be getting tired of karma fortunes by now.Sirtel ought to be getting tired of karma fortunes by now.Sirtel ought to be getting tired of karma fortunes by now.Sirtel ought to be getting tired of karma fortunes by now.Sirtel ought to be getting tired of karma fortunes by now.Sirtel ought to be getting tired of karma fortunes by now.
 
Sirtel's Avatar
 
Posts: 10,145
Karma: 224760044
Join Date: Jan 2014
Location: Estonia
Device: Kobo Sage & Libra 2
Unfortunately there is no real solution for kepub. There is a patch addressing the issue, but I haven't gotten it to work properly.
Sirtel is online now   Reply With Quote
Old 03-25-2024, 04:41 PM   #3
Aleron Ives
Wizard
Aleron Ives ought to be getting tired of karma fortunes by now.Aleron Ives ought to be getting tired of karma fortunes by now.Aleron Ives ought to be getting tired of karma fortunes by now.Aleron Ives ought to be getting tired of karma fortunes by now.Aleron Ives ought to be getting tired of karma fortunes by now.Aleron Ives ought to be getting tired of karma fortunes by now.Aleron Ives ought to be getting tired of karma fortunes by now.Aleron Ives ought to be getting tired of karma fortunes by now.Aleron Ives ought to be getting tired of karma fortunes by now.Aleron Ives ought to be getting tired of karma fortunes by now.Aleron Ives ought to be getting tired of karma fortunes by now.
 
Posts: 1,026
Karma: 11500112
Join Date: Sep 2022
Device: Kobo Libra 2
The font menu overrides all fonts when you're using KEPUB. The only way to display the book with multiple fonts is to edit the CSS to use all the fonts you want ahead of time and then select the publisher font option, i.e. you're half way there. Instead of setting only the sans-serif font in the book, you need to define the serif font, as well.
Aleron Ives is offline   Reply With Quote
Old 03-25-2024, 05:33 PM   #4
repilo
Enthusiast
repilo began at the beginning.
 
Posts: 43
Karma: 10
Join Date: Apr 2021
Location: Spain
Device: Kobo Libra 2
Thanks for the answers. I would have liked, using kepub, to be able to change the general font when I get tired of one and want to try another, but always keeping the captions with a sans serif font.
Another example would be a book about ancient Rome, with chapter titles and drop caps set with some ancient font (which I don't want to change) and the general text with a serif that I would be able to change when I feel like it.
That would be nice, Kobo, if you're listening.
repilo is offline   Reply With Quote
Old 03-25-2024, 06:03 PM   #5
Aleron Ives
Wizard
Aleron Ives ought to be getting tired of karma fortunes by now.Aleron Ives ought to be getting tired of karma fortunes by now.Aleron Ives ought to be getting tired of karma fortunes by now.Aleron Ives ought to be getting tired of karma fortunes by now.Aleron Ives ought to be getting tired of karma fortunes by now.Aleron Ives ought to be getting tired of karma fortunes by now.Aleron Ives ought to be getting tired of karma fortunes by now.Aleron Ives ought to be getting tired of karma fortunes by now.Aleron Ives ought to be getting tired of karma fortunes by now.Aleron Ives ought to be getting tired of karma fortunes by now.Aleron Ives ought to be getting tired of karma fortunes by now.
 
Posts: 1,026
Karma: 11500112
Join Date: Sep 2022
Device: Kobo Libra 2
If Kobo did that, then you'd have the opposite problem: people need to be able to change the font for accessibility, and if the font menu doesn't override all the fonts, then you may be stuck with some unreadable text if the publisher selected a bad font for certain paragraph styles. There's no universal solution except to edit the book beforehand with the fonts you want. If you like randomly changing the font for fun, then you have a lot of extra work ahead of you.
Aleron Ives is offline   Reply With Quote
Old 03-25-2024, 06:05 PM   #6
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 repilo View Post
Thanks for the answers. I would have liked, using kepub, to be able to change the general font when I get tired of one and want to try another, but always keeping the captions with a sans serif font.
Another example would be a book about ancient Rome, with chapter titles and drop caps set with some ancient font (which I don't want to change) and the general text with a serif that I would be able to change when I feel like it.
That would be nice, Kobo, if you're listening.
Kobo probably won't change their default override CSS for kepubs because it would upset as many users as it would please.

As soon as you choose anything other than 'Publisher Default' from the [Aa] menu then this sledgehammer override CSS is applied to your kepub:
Code:
* { font-family: %1 !important;}
where your selection from the font menu replaces the %1 placeholder. It's not possible to be more heavy-handed than this.

If you want a lighter touch with the override CSS you have 2 choices:
  1. Use the patch named Un-Force user font-family in KePubs in the kobopatch utility where you can patch your Kobo's firmware to use one of the following less severe options rather than the one above:
    Code:
    div,p{font-family:%1!important; }
    body,p{font-family:%1!important;}
    body{font-family:%1 !important; }
  2. Use epub instead of kepub, where the override will be at the body, p levels, i.e. like the middle kobopatch option above

@Sirtel, I don't know why the patch isn't working for you, it works fine for me. If you want to pursue it, feel free to PM me with a link to a book it doesn't work for.
jackie_w is offline   Reply With Quote
Old 03-25-2024, 07:08 PM   #7
Quoth
the rook, bossing Never.
Quoth ought to be getting tired of karma fortunes by now.Quoth ought to be getting tired of karma fortunes by now.Quoth ought to be getting tired of karma fortunes by now.Quoth ought to be getting tired of karma fortunes by now.Quoth ought to be getting tired of karma fortunes by now.Quoth ought to be getting tired of karma fortunes by now.Quoth ought to be getting tired of karma fortunes by now.Quoth ought to be getting tired of karma fortunes by now.Quoth ought to be getting tired of karma fortunes by now.Quoth ought to be getting tired of karma fortunes by now.Quoth ought to be getting tired of karma fortunes by now.
 
Quoth's Avatar
 
Posts: 11,164
Karma: 85874891
Join Date: Jun 2017
Location: Ireland
Device: All 4 Kinds: epub eink, Kindle, android eink, NxtPaper11
Quote:
Originally Posted by repilo View Post
Another example would be a book about ancient Rome, with chapter titles and drop caps set with some ancient font (which I don't want to change) and the general text with a serif that I would be able to change when I feel like it.
That would be nice, Kobo, if you're listening.
Mediaeval Germany might be a better example

This was the Roman Alphabet 2000 years ago
A B C D E F Z G H I K L M N O P Q R S T V X . They had no upper and lower case. That's close to the letter style used. C was pronounced K, like in Irish today, hence Caesar -> Kaiser. J was very much later simply I (or a Y sound) at the start of a word. No J.
Lower case was invented in Ireland 600 years later, and was used in Ireland till about 120 years ago. It's similar to current lower case. It became Carolingian minuscule

German Blackletter was used later, from about 11thC to 1941 when Hitler discontinued it (no-one is completely bad, just 99.99% bad).
People might use a Fraktur family font for Blackletter headings of Gothic stuff. The Old English font is related and nothing to do with Old English. It's slightly more readable than German Blackletter.
Blackletter, especially as body font, is very inaccessible.

The User Font selection should have an Advanced setting where you pick fonts for sans, serif, monospace, cursive and decorative and have the option to leave headings unchanged.

The "apply this font to everything" sledgehammer is lazy accessibility. Serif as a body and Sans as headings is a common choice. People used to web sites might want sans for body. People most easily read what they are used to.

Quote:
Generic Font Families

In CSS there are five generic font families:

Serif fonts have a small stroke at the edges of each letter. They create a sense of formality and elegance.
Sans-serif fonts have clean lines (no small strokes attached). They create a modern and minimalistic look.
Monospace fonts - here all the letters have the same fixed width. They create a mechanical look.
Cursive fonts imitate human handwriting.
Fantasy fonts are decorative/playful fonts.
Good font declarations in CSS should also declare one of the five generic fonts as well as the desired font. Font families often have Sans and Serif versions. Cursive is not Italic or Oblique.
Code:
.p1 {
  font-family: "Times New Roman", Times, serif;
}

.p2 {
  font-family: Arial, Helvetica, sans-serif;
}

.p3 {
  font-family: "Lucida Console", "Courier New", monospace;
}
You can just have the preferred and the generic.
https://www.w3schools.com/Css/css_font.asp

It's managers and programmers that don't seem to understand accessibility.

Last edited by Quoth; 03-25-2024 at 07:16 PM.
Quoth is offline   Reply With Quote
Old 03-26-2024, 05:26 AM   #8
repilo
Enthusiast
repilo began at the beginning.
 
Posts: 43
Karma: 10
Join Date: Apr 2021
Location: Spain
Device: Kobo Libra 2
Quote:
Originally Posted by Aleron Ives View Post
If Kobo did that, then you'd have the opposite problem: people need to be able to change the font for accessibility, and if the font menu doesn't override all the fonts, then you may be stuck with some unreadable text if the publisher selected a bad font for certain paragraph styles.
It seems that this is not a problem for Kobo when the format is epub. I have one with font-family:sans-serif in figcaption and it is respected even if I change to another font in the Aa menu (even OpenDyslexic). Why aren't they consistent and follow the same philosophy with both formats?

I still prefer kepub for other reasons.
repilo is offline   Reply With Quote
Old 03-26-2024, 05:13 PM   #9
Aleron Ives
Wizard
Aleron Ives ought to be getting tired of karma fortunes by now.Aleron Ives ought to be getting tired of karma fortunes by now.Aleron Ives ought to be getting tired of karma fortunes by now.Aleron Ives ought to be getting tired of karma fortunes by now.Aleron Ives ought to be getting tired of karma fortunes by now.Aleron Ives ought to be getting tired of karma fortunes by now.Aleron Ives ought to be getting tired of karma fortunes by now.Aleron Ives ought to be getting tired of karma fortunes by now.Aleron Ives ought to be getting tired of karma fortunes by now.Aleron Ives ought to be getting tired of karma fortunes by now.Aleron Ives ought to be getting tired of karma fortunes by now.
 
Posts: 1,026
Karma: 11500112
Join Date: Sep 2022
Device: Kobo Libra 2
EPUB uses RMSDK for rendering. KEPUB uses WebKit. They're completely different engines. One of the reasons I prefer KEPUB is that it does support total font replacement. EPUB books can be formatted to forbid you from changing the font, but in KEPUB this formatting is ignored, which allows you to change the font without having to edit the book's CSS. Different people want different things.
Aleron Ives is offline   Reply With Quote
Reply


Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
Is it possible to change the menu font? tesseractcat KOReader 2 03-09-2019 06:27 PM
Change to interface font doesn't stick eater Calibre 3 02-21-2018 03:46 PM
Touch Change font by editing ePub CSS ExOblivione Barnes & Noble NOOK 8 12-25-2012 12:48 AM
How to change the font-size in the body tag in css? naisren Conversion 2 10-01-2012 05:52 PM
Hacks First post here. Can I change the size of the default font set? johnleo Amazon Kindle 3 08-09-2012 01:23 PM


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


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