Quote:
Originally Posted by tshering
Now I remember that I once tried to reference a font in the css with the res-scheme, but I did not get it to work. Maybe I misunderstand how to resolve the path.
|
Taking inspiration from these last few posts I decided to give this one more go... and guess what, I finally found a res:/// path you can use to directly reference sideloaded fonts stored in the Kobo int.mem /fonts directory from the epub css file, i.e. no embedded fonts required.
To solve my long-standing problem accessing a sideloaded monospace font (only for selected css classes of an epub), this works on KoboGlo fw 2.1.5, if you add it to the epub's css file (not tested with fw 2.4.0 as I haven't decided whether to upgrade yet):
Code:
@font-face {font-family: monospace; font-weight: normal; font-style: normal; src: url('res:///fonts/normal/Dark Courier')}
@font-face {font-family: monospace; font-weight: normal; font-style: italic; src: url('res:///fonts/italic/Dark Courier')}
@font-face {font-family: monospace; font-weight: bold; font-style: normal; src: url('res:///fonts/bold/Dark Courier')}
@font-face {font-family: monospace; font-weight: bold; font-style: italic; src: url('res:///fonts/bolditalic/Dark Courier')}
where the
red name is exactly as it appears in the font settings drop-down list.
With the above @font-faces any css class defined with
font-family: monospace; will be directed to use the sideloaded
Dark Courier monospace font rather than the Kobo default i.e. the same as the one you selected in font settings for main body font.
Similarly, and for completeness:
If you have selected css classes (e.g. headings) containing
font-family: sans-serif; then adding this to the css file would result in sideloaded font
Trebuchet MS being displayed rather than the Kobo default (Avenir I think):
Code:
@font-face {font-family: sans-serif; font-weight: normal; font-style: normal; src: url('res:///fonts/normal/Trebuchet MS')}
@font-face {font-family: sans-serif; font-weight: normal; font-style: italic; src: url('res:///fonts/italic/Trebuchet MS')}
@font-face {font-family: sans-serif; font-weight: bold; font-style: normal; src: url('res:///fonts/bold/Trebuchet MS')}
@font-face {font-family: sans-serif; font-weight: bold; font-style: italic; src: url('res:///fonts/bolditalic/Trebuchet MS')}
and if you want to use a proper small-caps font where the css class contains something like
font-family: "SCfont"; then adding this to the css file would result in sideloaded font
Charis SIL SmCp being displayed (rather than the Kobo default, i.e. the same one you selected in font settings for main body font:
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: normal; font-style: italic; src: url('res:///fonts/italic/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: bold; font-style: italic; src: url('res:///fonts/bolditalic/Charis SIL SmCp')}
I realise this will not appeal to the majority of users but I've documented it anyway. Anyone, like me, who's moved to Kobo from an older Sony may have been using similar css overriding techniques with the PRS+ custom firmware.
Unfortunately, I haven't managed to figure out the 'magic formula' required to reference a sideloaded css file containing widows/orphans statements. I've tried the technique which works on a Sony PRST1 (unhacked), but no joy.