Quote:
Originally Posted by HarryGeez
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"> </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.