![]() |
#1 |
Resident Curmudgeon
![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() Posts: 79,205
Karma: 144286760
Join Date: Nov 2006
Location: Roslindale, Massachusetts
Device: Kobo Libra 2, Kobo Aura H2O, PRS-650, PRS-T1, nook STR, PW3
|
Accessing fonts from CSS
Is there a way to reference fonts that are installed someplace on the Kobo Reader without actually embedding them? I ask because while you can use your choice of fonts, you cannot use more then one font family. So if I want true small caps (for example), I'd have to embed both font families. On 650 & T1, I can use CSS code to access the fonts installed on the Readers without having to embed them in the eBooks. Can I do this on a Kobo Reader using firmware 3.8.0?
Last edited by JSWolf; 10-19-2014 at 11:01 AM. |
![]() |
![]() |
![]() |
#2 | |
Wizard
![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() Posts: 3,821
Karma: 19162882
Join Date: Nov 2012
Location: Te Riu-a-Māui
Device: Kobo Glo
|
Quote:
|
|
![]() |
![]() |
Advert | |
|
![]() |
#3 | |
Grand Sorcerer
![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() Posts: 6,249
Karma: 16539642
Join Date: Sep 2009
Location: UK
Device: ClaraHD, Forma, Libra2, Clara2E, LibraCol, PBTouchHD3
|
Quote:
Code:
@font-face {font-family: "SCfont"; font-weight: normal; font-style: normal; src: url("res:///fonts/normal/Charis SIL SmCp")} @font-face {font-family: "SCfont"; font-weight: bold; font-style: normal; src: url("res:///fonts/bold/Charis SIL SmCp")} @font-face {font-family: "SCfont"; font-weight: normal; font-style: italic; src: url("res:///fonts/italic/Charis SIL SmCp")} @font-face {font-family: "SCfont"; font-weight: bold; font-style: italic; src: url("res:///fonts/bolditalic/Charis SIL SmCp")} The Charis SIL SmCp must match the font's internal and external name. |
|
![]() |
![]() |
![]() |
#4 |
frumious Bandersnatch
![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() Posts: 7,543
Karma: 19001583
Join Date: Jan 2008
Location: Spaniard in Sweden
Device: Cybook Orizon, Kobo Aura
|
|
![]() |
![]() |
![]() |
#5 |
Resident Curmudgeon
![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() Posts: 79,205
Karma: 144286760
Join Date: Nov 2006
Location: Roslindale, Massachusetts
Device: Kobo Libra 2, Kobo Aura H2O, PRS-650, PRS-T1, nook STR, PW3
|
|
![]() |
![]() |
Advert | |
|
![]() |
#6 |
Evangelist
![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() Posts: 469
Karma: 600816
Join Date: Sep 2009
Device: Kobo Aura HD, Kobo Aura One
|
A somewhat related question. I have tried to use the technique described by jackie_w to add monospace fonts and occasionally it would result in the book ignoring ALL CSS, while other books worked fine. Can anyone spot anything wrong with my kobo_extra.css?
Code:
@font-face {font-family: monospace; font-weight: normal; font-style: normal; src: url("res:///fonts/normal/Consolas")} @font-face {font-family: monospace; font-weight: bold; font-style: normal; src: url("res:///fonts/bold/Consolas")} @font-face {font-family: monospace; font-weight: normal; font-style: italic; src: url("res:///fonts/italic/Consolas")} @font-face {font-family: monospace; font-weight: bold; font-style: italic; src: url("res:///fonts/bolditalic/Consolas")} pre, code, tt { font-family: monospace; font-size: 80%; } |
![]() |
![]() |
![]() |
#7 |
Guru
![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() Posts: 600
Karma: 641742
Join Date: Mar 2012
Location: DE
Device: Kobo Glo
|
@dmapr. There is nothing wrong with your code.
Are you sure that the original stylesheet is correct? A minor error (i.e. a missing semicolon ; ) will break the CSS on Kobo ereaders while Sigil displays the output as intended. CSS Validation Tool: http://jigsaw.w3.org/css-validator/validator |
![]() |
![]() |
![]() |
#8 |
Grand Sorcerer
![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() Posts: 6,249
Karma: 16539642
Join Date: Sep 2009
Location: UK
Device: ClaraHD, Forma, Libra2, Clara2E, LibraCol, PBTouchHD3
|
Another thing to try... I've also experienced all css being ignored. Find a book with the problem and have a look at its internal css. Do you see any occurrences of !important in there? If so remove them and try again.
|
![]() |
![]() |
![]() |
#9 | |
Evangelist
![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() Posts: 469
Karma: 600816
Join Date: Sep 2009
Device: Kobo Aura HD, Kobo Aura One
|
Quote:
Thanks for the tip. Next time I run into this I'll check for that. |
|
![]() |
![]() |
![]() |
#10 |
Evangelist
![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() Posts: 469
Karma: 600816
Join Date: Sep 2009
Device: Kobo Aura HD, Kobo Aura One
|
@jackie_w, finally ran into this again — you're right, the CSS had a few (seemingly unrelated) rules with !important. Removing the !important fixed things. Any idea why adding font references would cause such an effect?
|
![]() |
![]() |
![]() |
#11 | |
Grand Sorcerer
![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() Posts: 6,249
Karma: 16539642
Join Date: Sep 2009
Location: UK
Device: ClaraHD, Forma, Libra2, Clara2E, LibraCol, PBTouchHD3
|
Quote:
![]() It may have absolutely nothing to do with adding font references. It may be some toxic combination of !important and the cssutils Python package which is used to apply the rules from your kobo_extra.css file - which just happen to be font references in your case. However, this doesn't make any sense to me either as I've no reason to believe there's anything wrong with cssutils (which I use every day for css tweaking) and !important is valid css. If you want to troubleshoot it, have you tried temporarily disabling kobo_extra.css and adding your font rules manually - also leaving the !important occurrences as-is? Does the Kobo still reject the whole css file? For myself I've side-stepped the problem by auto-removing all occurrences of !important whenever I tweak css because I can see no good reason for a well-constructed book to need them in the internal css. |
|
![]() |
![]() |
![]() |
#12 | |
Evangelist
![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() Posts: 469
Karma: 600816
Join Date: Sep 2009
Device: Kobo Aura HD, Kobo Aura One
|
Quote:
![]() I ended up doing the same thing you do — I strip out all !important from the CSS. In all cases I've seen so far it was in the CSS I had absolutely no interest in to begin with. Last edited by dmapr; 07-03-2015 at 11:02 AM. |
|
![]() |
![]() |
![]() |
|
![]() |
||||
Thread | Thread Starter | Forum | Replies | Last Post |
How to invoke different fonts in CSS 2.3.1? | xuyn2003 | Kobo Reader | 32 | 01-06-2013 09:52 PM |
working with fonts in css | jayz | Kindle Formats | 9 | 10-29-2012 04:09 PM |
PRS-T1 Adding two fonts into the CSS? | WarGhSt | Sony Reader | 1 | 02-02-2012 01:41 AM |
Opus Fonts directory for Calibre -> External CSS | fiery | Bookeen | 12 | 02-20-2011 10:05 PM |
nook fonts via CSS | danrodney | Barnes & Noble NOOK | 1 | 12-21-2010 07:56 AM |