View Single Post
Old 05-29-2019, 01:59 PM   #104
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,252
Karma: 16544692
Join Date: Sep 2009
Location: UK
Device: ClaraHD, Forma, Libra2, Clara2E, LibraCol, PBTouchHD3
Quote:
Originally Posted by Gorcsev View Post
I have the following in my CSS:
.mono {
display: block;
font-family: monospace;
text-align: justify;
line-height: 130%;
widows: 2;
orphans: 2;
}

with the intention to display monospaced fonts in epub. It works in epub. Could it be reached in kebub as well without using embedded fonts?
This may be more effort than you're prepared to do, but you could experiment with this:
  1. Kobos don't have any built-in monospace font files so you first need to sideload one. For this example assume you sideloaded the 4 "Courier New" font-family files. You probably also need to power off/on to get the new font properly recognised by the Kobo.
  2. You will also need to use the kobopatch system to patch the firmware's override CSS file for kepubs. If you don't you'll be wasting your time with the rest because the default override CSS for font-family on kepubs is:
    Code:
    * { font-family: %1 !important; }
    i.e. whatever font you pick from the font menu will be used for absolutely everything.

    The relevant patch name is 'Un-Force user font-family in KePubs' and there are 3 different options to choose from.

  3. Code your book CSS like this, where the red bit is the exact internal font name of your sideloaded font.
    Code:
    .mono {
      ...
      font-family: "Courier New", monospace;
      ...
    }
    You won't need to add @font-faces for kepub, the correct font name is enough.

    This CSS should work equally well no matter whether you transfer the book as a kepub or a standard epub.

Item 1 needs to be done only once per Kobo device.
Item 2 needs to be done after every firmware update.
Item 3 needs to be done for every book which needs a monospace font.
jackie_w is offline   Reply With Quote