![]() |
#1 |
Member
![]() Posts: 19
Karma: 10
Join Date: May 2020
Device: Kobo Clara HD
|
![]()
I have an epub that has code snippets that are displaying as just smaller version of the regular font face. When I opened the file in Calibre, I noticed that the only CSS applied to the
Code:
pre Code:
font-size: x-small; Code:
font-familly: Courier; |
![]() |
![]() |
![]() |
#2 |
Resident Curmudgeon
![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() Posts: 79,070
Karma: 144284144
Join Date: Nov 2006
Location: Roslindale, Massachusetts
Device: Kobo Libra 2, Kobo Aura H2O, PRS-650, PRS-T1, nook STR, PW3
|
If you are using KePub, you have to embed a monospace font.
If you are using a ePub you want to put a font with the name Courier in the fonts directory. In the ePub, put the following code in the CSS. That will link the fonts to the ePub without the need to embed. 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); } |
![]() |
![]() |
![]() |
#3 |
Member
![]() Posts: 19
Karma: 10
Join Date: May 2020
Device: Kobo Clara HD
|
Forgive my ignorance, but how do I know which format Calibre is sending to my device? I just use the "Send to device" button which doesn't ask if I want to convert.
I tried adding the code you provided, but it didn't make a difference. |
![]() |
![]() |
![]() |
#4 |
Resident Curmudgeon
![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() Posts: 79,070
Karma: 144284144
Join Date: Nov 2006
Location: Roslindale, Massachusetts
Device: Kobo Libra 2, Kobo Aura H2O, PRS-650, PRS-T1, nook STR, PW3
|
Did you put a font family named Courier in the fonts directory? Also, you have to be reading ePub. That code will not work with KePub.
|
![]() |
![]() |
![]() |
#5 | |
Member
![]() Posts: 19
Karma: 10
Join Date: May 2020
Device: Kobo Clara HD
|
Quote:
Code:
cour.ttf |
|
![]() |
![]() |
![]() |
#6 | |
Member
![]() Posts: 19
Karma: 10
Join Date: May 2020
Device: Kobo Clara HD
|
Quote:
Code:
cour*.ttf I looked at the file system on my reader and I do see the file as having a weird double extension Code:
.kepub.epub |
|
![]() |
![]() |
![]() |
#7 |
Member
![]() Posts: 19
Karma: 10
Join Date: May 2020
Device: Kobo Clara HD
|
I found a reddit thread that says to just copy the epub file from my computer's file system to the reader, but that just results in a file that locks up the reader for several seconds if I try to navigate using the table of contents, and the code is still not monospaced.
|
![]() |
![]() |
![]() |
#8 |
Running with scissors
![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() Posts: 1,582
Karma: 14328510
Join Date: Nov 2019
Device: none
|
Code:
.kepub.epub |
![]() |
![]() |
![]() |
#9 |
Member
![]() Posts: 19
Karma: 10
Join Date: May 2020
Device: Kobo Clara HD
|
|
![]() |
![]() |
![]() |
#10 |
Resident Curmudgeon
![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() Posts: 79,070
Karma: 144284144
Join Date: Nov 2006
Location: Roslindale, Massachusetts
Device: Kobo Libra 2, Kobo Aura H2O, PRS-650, PRS-T1, nook STR, PW3
|
|
![]() |
![]() |
![]() |
#11 |
Member
![]() Posts: 19
Karma: 10
Join Date: May 2020
Device: Kobo Clara HD
|
I understand that. That's why I looked for a way to send an epub to the Kobo (and have it stay as that extension). That however didn't work. Since it looks like I'll have to stick with KePub, how do I embed the monospace fonts like you suggest?
|
![]() |
![]() |
![]() |
#12 |
Bibliophagist
![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() Posts: 44,727
Karma: 168431851
Join Date: Jul 2010
Location: Vancouver
Device: Kobo Sage, Libra Colour, Lenovo M8 FHD, Paperwhite 4, Tolino epos
|
Which KoboTouch driver are you using to send the ebook to your Kobo? If you are using the KoboTouch driver, it will send epubs. If you are using the KoboTouchExtended driver, it will send kepubs (.kepub.epub file extension).
If you have KoboUtilities installed, you can switch the active driver from it's menu. Otherwise, you can open Preferences => Plugins, search for kobot and disable the KoboTouchExtended driver and enable the KoboTouch driver. If you have done any customization in the driver, you will need to copy it over. |
![]() |
![]() |
![]() |
#13 |
Member
![]() Posts: 19
Karma: 10
Join Date: May 2020
Device: Kobo Clara HD
|
I suspect my CSS is not up to snuff. Here's what I have in the style file:
Code:
.pre { font-family: monospace; } @font-face { font-family: monospace; font-weight: normal; font-style: normal; src: url(res:///Data/fonts/cour.ttf); } @font-face { font-family: monospace; font-weight: bold; font-style: normal; src: url(res:///Data/fonts/courbd.ttf); } @font-face { font-family: monospace; font-weight: normal; font-style: italic; src: url(res:///Data/fonts/couri.ttf); } @font-face { font-family: monospace; font-weight: bold; font-style: italic; src: url(res:///Data/fonts/courbi.ttf); } Also, the regular epub format doesn't seem to play very nicely. As I mentioned earlier, trying to use the table of contents (either in the book or the reader's ToC function) just locks up the reader for ~30 seconds, after which it automatically restarts. If this is because it's an epub vs a kepub, then how can I get the font to work correctly in a kepub? |
![]() |
![]() |
![]() |
#14 | |
Resident Curmudgeon
![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() Posts: 79,070
Karma: 144284144
Join Date: Nov 2006
Location: Roslindale, Massachusetts
Device: Kobo Libra 2, Kobo Aura H2O, PRS-650, PRS-T1, nook STR, PW3
|
Quote:
In the KoboTouchExtended driver, go to the Extended tab and check Use template for kepubification. This is the code I am using for the template. Code:
program: $#kepub == 'yes' Last edited by JSWolf; 06-07-2023 at 07:15 AM. |
|
![]() |
![]() |
![]() |
#15 | |
Grand Sorcerer
![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() Posts: 6,248
Karma: 16539642
Join Date: Sep 2009
Location: UK
Device: ClaraHD, Forma, Libra2, Clara2E, LibraCol, PBTouchHD3
|
Quote:
Assuming that you're using one of the stock Kobo reading apps (i.e. not KOReader) then the following is the way to get a monospace font working on any Kobo firmware >= 4.32.xxxxx: Epub:
Kepub: Ever since firmware 4.32.xxxxx, the only option is to embed a monospace font into each book that needs it. If you embed the font then it should work equally well as either epub or kepub. Last edited by jackie_w; 06-07-2023 at 08:10 PM. |
|
![]() |
![]() |
![]() |
Tags |
code, css, preformatted |
|
![]() |
||||
Thread | Thread Starter | Forum | Replies | Last Post |
Code View font choices | tetrault | Sigil | 3 | 05-28-2019 03:11 PM |
Change to interface font doesn't stick | eater | Calibre | 3 | 02-21-2018 03:46 PM |
Can't set preferred font in Sigil Code Editor window | GrannyGrump | Sigil | 2 | 01-26-2014 11:43 PM |
Calling all font and code experts | ltr | Kobo Reader | 7 | 12-09-2011 08:28 PM |
Changing font for code view mode | matthewyi | Sigil | 2 | 11-05-2009 02:20 PM |