View Single Post
Old 03-08-2015, 06:53 PM   #6
DNSB
Bibliophagist
DNSB ought to be getting tired of karma fortunes by now.DNSB ought to be getting tired of karma fortunes by now.DNSB ought to be getting tired of karma fortunes by now.DNSB ought to be getting tired of karma fortunes by now.DNSB ought to be getting tired of karma fortunes by now.DNSB ought to be getting tired of karma fortunes by now.DNSB ought to be getting tired of karma fortunes by now.DNSB ought to be getting tired of karma fortunes by now.DNSB ought to be getting tired of karma fortunes by now.DNSB ought to be getting tired of karma fortunes by now.DNSB ought to be getting tired of karma fortunes by now.
 
DNSB's Avatar
 
Posts: 46,648
Karma: 169712392
Join Date: Jul 2010
Location: Vancouver
Device: Kobo Sage, Libra Colour, Lenovo M8 FHD, Paperwhite 4, Tolino epos
Quote:
Originally Posted by HarryGeez View Post
I have a few programming epubs and the Kobo Aura's epub reader doesn't seem to respect the epubs' CSS. It seems that people expect the reader to ignore books' CSS so that all books have a uniform look, but this is crucial for programming books because if monospace fonts and margins are not respected, it's impossible to read the code examples.
First question would be what format are you reading the books in? The standard epub or Kobo's modified epub (generally called kepub). The ACCESS renderer used for kepubs does tend to disregard some CSS styles but the Adobe RMSDK renderer used for standard epubs does a pretty decent job of following the epub2 standard (other than using auto/auto for center stuff and smallcaps). Monospaced text is going to require you to install a monospace font since there is not one present by default and add the CSS references to it. For myself, I installed HP's Dark Courier font and the following CSS entries:

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');
    }

code {
    font-family : "Dark Courier", monospace;
    }
I then add the code start/end tags around any monospaced text. An example from Andy Weir's The Martian for a computer bootup sequence.

Code:
  <p class="nonindent1 bold"><code>PATHFINDER LOG: SOL 0</code></p>

  <p class="indent2"><code>BOOT SEQUENCE INITIATED</code></p>

  <p class="indent2"><code>TIME 00:00:00</code></p>

  <p class="indent2"><code>LOSS OF POWER DETECTED, TIME/DATE UNRELIABLE</code></p>

  <p class="indent2"><code>LOADING OS...</code></p>

  <p class="indent2break">&nbsp;</p>

  <p class="indent2"><code>VXWARE OPERATING SYSTEM (C) WIND RIVER SYSTEMS</code></p>

  <p class="indent2"><code>PERFORMING HARDWARE CHECK:</code></p>

  <p class="indent2"><code>INT. TEMPERATURE: -34C</code></p>

  <p class="indent2"><code>EXT. TEMPERATURE: NONFUNCTIONAL</code></p>

  <p class="indent2"><code>BATTERY: FULL</code></p>

  <p class="indent2"><code>HIGAIN: OK</code></p>
Several other ebooks I own already had the code tags wrapped around monospaced text so simply adding the CSS code to the start of the stylesheet is all that is needed.

Last edited by DNSB; 03-08-2015 at 06:57 PM.
DNSB is offline   Reply With Quote