View Single Post
Old 05-23-2024, 08:15 PM   #5
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,410
Karma: 169098492
Join Date: Jul 2010
Location: Vancouver
Device: Kobo Sage, Libra Colour, Lenovo M8 FHD, Paperwhite 4, Tolino epos
Quote:
Originally Posted by JSWolf View Post
Monospace does not work out of the box. You can get monospace to work with KePub by embedding a monospace font. But you can do it even easier if you use ePub.

Spoiler:
The first thing to do it find a Courier font. name the font files...
Courier-Regular.ttf
Courier-Bold.ttf
Courier-Italic.ttf
Courier-BoldItalic.ttf

Put them in the fonts directory. Then in the CSS, use the following code.

Code:
@font-face {
font-family:monospace;
font-weight: normal;
font-style: normal;
src: url(res:///Data/fonts/Courier-Regular.ttf);
}
@font-face {
font-family:monospace;
font-weight: bold;
font-style: normal;
src: url(res:///Data/fonts/Courier-Bold.ttf);
}
@font-face {
font-family:monospace;
font-weight: normal;
font-style: italic;
src: url(res:///Data/fonts/Courier-Italic.ttf);
}
@font-face {
font-family:monospace;
font-weight: bold;
font-style: italic;
src: url(res:///Data/fonts/Courier-BoldItalic.ttf);
}


Now when you have font-family: monospace; you will have a monospace font displayed.
In my testing, if you have the font named Courier, you do not need to add the font-face declarations in the CSS for an ePub. Just adding <code> around the text that you want to be monospaced is all that is needed.
DNSB is online now   Reply With Quote