Register Guidelines E-Books Search Today's Posts Mark Forums Read

Go Back   MobileRead Forums > E-Book Readers > Kobo Reader

Notices

Reply
 
Thread Tools Search this Thread
Old 05-02-2017, 12:58 AM   #1
TuxGirl
Groupie
TuxGirl can grip it by the huskTuxGirl can grip it by the huskTuxGirl can grip it by the huskTuxGirl can grip it by the huskTuxGirl can grip it by the huskTuxGirl can grip it by the huskTuxGirl can grip it by the huskTuxGirl can grip it by the huskTuxGirl can grip it by the huskTuxGirl can grip it by the huskTuxGirl can grip it by the husk
 
Posts: 178
Karma: 141378
Join Date: Sep 2009
Device: kindle
getting monospace font to work correctly with KoboTouchExtended driver?

I have been following the instructions at this post:
https://www.mobileread.com/forums/sh...48&postcount=8

If I use the KoboTouch driver, I seem to be able to get a monospace font in the Font Family Defaults test file, but when I use the KoboTouchExtended driver, I don't seem to be getting the monospace font. Is that normal? Is everyone generally using straight epubs if they want to have monospace fonts?

Thanks!
TuxGirl is offline   Reply With Quote
Old 05-02-2017, 05:17 AM   #2
GeoffR
Wizard
GeoffR ought to be getting tired of karma fortunes by now.GeoffR ought to be getting tired of karma fortunes by now.GeoffR ought to be getting tired of karma fortunes by now.GeoffR ought to be getting tired of karma fortunes by now.GeoffR ought to be getting tired of karma fortunes by now.GeoffR ought to be getting tired of karma fortunes by now.GeoffR ought to be getting tired of karma fortunes by now.GeoffR ought to be getting tired of karma fortunes by now.GeoffR ought to be getting tired of karma fortunes by now.GeoffR ought to be getting tired of karma fortunes by now.GeoffR ought to be getting tired of karma fortunes by now.
 
GeoffR's Avatar
 
Posts: 3,821
Karma: 19159830
Join Date: Nov 2012
Location: Te Riu-a-Māui
Device: Kobo Glo
Quote:
Originally Posted by TuxGirl View Post
I have been following the instructions at this post:
https://www.mobileread.com/forums/sh...48&postcount=8

If I use the KoboTouch driver, I seem to be able to get a monospace font in the Font Family Defaults test file, but when I use the KoboTouchExtended driver, I don't seem to be getting the monospace font. Is that normal? Is everyone generally using straight epubs if they want to have monospace fonts?!
The KePub reader is very different from the ePub reader in the way it handles fonts.

The main problem with the KePub reader is that if you select a font from the device menu then it will override all other fonts in the book. So without patching the firmware the only way to have a monospace font in a KePub is either to select "Publisher default" from the menu (so only fonts set by the book's publisher are used), or select a sideloaded monospace font from the device menu (in which case the whole book will be displayed in monospace.)

The ePub reader is different, it allows you to select a font from the device menu but still allows the publisher to override the selected font in the ebook, so if the publisher has done it right then you can have your own choice of font for the main text but still have some things displayed in other font faces, such as monospace for computer code etc.

If you are willing to patch the firmware then you can make it so the KePub reader doesn't override all of the publisher's fonts when you select a font from the device menu, the relevent patch is called `Un-Force user font-family in KePubs`.

(There is also a patch for the ePub reader called `Default ePub monospace font (Courier)` that makes the device use a sideloaded Courier font as the default monospace font, which avoids the need to use @font-face to define the monospace font in the ePub book's stylesheet as the link you gave above was doing.)

Edit: If you have selected "Publisher default" in a KePub and the monospace font is still not being displayed, then perhaps the method of defining @font-face:monospace doesn't work in KePubs. The KePub reader has its own definition and uses the default sans-serif font (Avenir Next) when font-family:monospace; is specified, and I'm not sure if that overrides the publisher's definition or not. You might need to replace "font-family:monospace;" with "font-family:Courier,monospace;" in the book for it to work in KePubs. (Assuming you have a monospaced font called Courier installed on the device.)

Last edited by GeoffR; 05-02-2017 at 06:06 AM. Reason: "Publisher default"
GeoffR is offline   Reply With Quote
Advert
Old 05-02-2017, 11:43 PM   #3
TuxGirl
Groupie
TuxGirl can grip it by the huskTuxGirl can grip it by the huskTuxGirl can grip it by the huskTuxGirl can grip it by the huskTuxGirl can grip it by the huskTuxGirl can grip it by the huskTuxGirl can grip it by the huskTuxGirl can grip it by the huskTuxGirl can grip it by the huskTuxGirl can grip it by the huskTuxGirl can grip it by the husk
 
Posts: 178
Karma: 141378
Join Date: Sep 2009
Device: kindle
So, interestingly, if I choose "Publisher Default" for the font, it uses a different font for the code, but it's not a monospace font... I have edited the css for the book to make sure the code has font-family:monospace, and in calibre, it uses a monospace font.

I also am using the kobo_extra.css to set which monospace font I would prefer to use, but that isn't used regardless.

I may have to try patching to see if I can get this thing to behave correctly.

Thanks!
TuxGirl is offline   Reply With Quote
Old 05-03-2017, 12:36 AM   #4
TuxGirl
Groupie
TuxGirl can grip it by the huskTuxGirl can grip it by the huskTuxGirl can grip it by the huskTuxGirl can grip it by the huskTuxGirl can grip it by the huskTuxGirl can grip it by the huskTuxGirl can grip it by the huskTuxGirl can grip it by the huskTuxGirl can grip it by the huskTuxGirl can grip it by the huskTuxGirl can grip it by the husk
 
Posts: 178
Karma: 141378
Join Date: Sep 2009
Device: kindle
Ok, I did patch to be able to use publisher font family, and now it uses a different font for the code than it does for everything else, even if I choose a custom font, but it still isn't using a monospaced font! I did also include the patch for Courier* fonts, and I have the "Courier New" font installed.

Interestingly, one effect that I'm seeing is that now the menu for selecting a font shows all the fonts in italic, but when I select them, they aren't italic. Not sure why that happened (and it could have happened when the kobo updated to 4.3.8945 earlier today), but I can definitely live with that.

So, maybe the problem is in my css file?

What I did was I looked through a page or two of the book, and I found the areas where there was code-listings, and looked at the <div>, <pre> and <code> tags that were used around code listings. Then, I went to the css file, and found the equivalent css listings for those tags. I added a "font-family:monospace;" to those css areas. It is working in calibre's preview area, but doesn't seem to be coming over correctly on the kobo?

It is convenient that in this book, all the parts that should be monospace are also blue, so I verified by making sure that every place in the css that has "color:blue" also has "font-family:monospace" after it.

Once again, it also is working correctly in the epub reader, but not in the kepub reader. So weird!
TuxGirl is offline   Reply With Quote
Old 05-03-2017, 12:46 AM   #5
TuxGirl
Groupie
TuxGirl can grip it by the huskTuxGirl can grip it by the huskTuxGirl can grip it by the huskTuxGirl can grip it by the huskTuxGirl can grip it by the huskTuxGirl can grip it by the huskTuxGirl can grip it by the huskTuxGirl can grip it by the huskTuxGirl can grip it by the huskTuxGirl can grip it by the huskTuxGirl can grip it by the husk
 
Posts: 178
Karma: 141378
Join Date: Sep 2009
Device: kindle
the other odd thing is that in the calibre viewer on another book (same publisher), it is showing the code samples as being monospace even though I can't figure out from the css how it knows that those sections are supposed to be monospaced.
TuxGirl is offline   Reply With Quote
Advert
Old 05-03-2017, 08:55 AM   #6
GeoffR
Wizard
GeoffR ought to be getting tired of karma fortunes by now.GeoffR ought to be getting tired of karma fortunes by now.GeoffR ought to be getting tired of karma fortunes by now.GeoffR ought to be getting tired of karma fortunes by now.GeoffR ought to be getting tired of karma fortunes by now.GeoffR ought to be getting tired of karma fortunes by now.GeoffR ought to be getting tired of karma fortunes by now.GeoffR ought to be getting tired of karma fortunes by now.GeoffR ought to be getting tired of karma fortunes by now.GeoffR ought to be getting tired of karma fortunes by now.GeoffR ought to be getting tired of karma fortunes by now.
 
GeoffR's Avatar
 
Posts: 3,821
Karma: 19159830
Join Date: Nov 2012
Location: Te Riu-a-Māui
Device: Kobo Glo
The KePub reader uses the default sans-serif font (Avenir) when you specify font-family:monospace; in the stylesheet. The trick with the ePub reader was to define "monospace" as the name of a monospace font you have installed, but I'm not sure whether that works for the KePub reader. From what you describe it sounds like it doesn't.

In that case you would need to edit the stylesheet in the book to change every instance of font-family:monospace; to font-family:"Courier New",monospace; to use your installed Courier New font as the monospace font. If the book uses <pre> tags for code then you'd also need to set pre {font-family:"Courier New",monospace;} in the stylesheet. That is a lot more work than for ePubs.

Edit: There is also a shorthand form: font: that some books use instead of font-family:. That would need to be changed too.

(I read some KePubs synced from the Kobo server, but I always sideload ePubs because the ePub reader does this typographical stuff much better than the KePub reader.)

The font selection menu showing Italics was a change in one of the recent firmware updates.

Last edited by GeoffR; 05-03-2017 at 09:04 AM. Reason: font: shorthand form
GeoffR is offline   Reply With Quote
Old 05-03-2017, 09:08 AM   #7
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: 5,368
Karma: 13600948
Join Date: Sep 2009
Location: UK
Device: Kobo: H2O, GloHD, KA1, ClaraHD, Forma
Quote:
Originally Posted by TuxGirl View Post
Interestingly, one effect that I'm seeing is that now the menu for selecting a font shows all the fonts in italic, but when I select them, they aren't italic. Not sure why that happened (and it could have happened when the kobo updated to 4.3.8945 earlier today), but I can definitely live with that.
This is due to a recent change in the firmware. I suspect it's just Kobo trying to standardise the appearance of all their drop-down menus to display entries as italic. Personally, I think it looks a bit weird on the font-family drop-down but, same as you, I can live with it.

As for your monospace problem ... welcome to the wonderful world of epub versus kepub

Although I've been using Kobos for years I didn't bother with kepubs at all until I got my KA1. Once I decided to give them a try it became clear how different they are when it comes to style issues (monospace, sans-serif, small-caps, hyphenation, ligatures and footnotes).

For kepubs, styling as monospace is actually easier in some ways than it is for epubs because all that's required is to change the CSS from font-family:monospace to font-family:"Courier New" (if "Courier New" is your chosen sideloaded monospace font) rather than needing to add @font-face statements. The obvious problem being that this requires manually editing every book which uses monospace.

This would be time-consuming but, worse than that, making these changes to your master epub in calibre would almost certainly be counter-productive if you also want to send the master epub to a different device, e.g. Android, or even if you change your mind and decide that standard epubs are preferable for the Kobo.

I did solve this conundrum for myself by customising my personal copy of the KoboTouchExtended plugin driver to make the necessary CSS changes on-the-fly during the calibre send-to-device process. This is obviously not an option for everyone but if you have some Python coding skills it's possible to do all sorts of interesting (OK, I'm a nerd ) stuff on-the-fly. Should you ever choose to go down this route feel free to PM me. I'm happy to share anything you'd find useful.
jackie_w is offline   Reply With Quote
Old 05-03-2017, 01:19 PM   #8
TuxGirl
Groupie
TuxGirl can grip it by the huskTuxGirl can grip it by the huskTuxGirl can grip it by the huskTuxGirl can grip it by the huskTuxGirl can grip it by the huskTuxGirl can grip it by the huskTuxGirl can grip it by the huskTuxGirl can grip it by the huskTuxGirl can grip it by the huskTuxGirl can grip it by the huskTuxGirl can grip it by the husk
 
Posts: 178
Karma: 141378
Join Date: Sep 2009
Device: kindle
Quote:
Originally Posted by jackie_w View Post
This is due to a recent change in the firmware. I suspect it's just Kobo trying to standardise the appearance of all their drop-down menus to display entries as italic. Personally, I think it looks a bit weird on the font-family drop-down but, same as you, I can live with it.

As for your monospace problem ... welcome to the wonderful world of epub versus kepub

Although I've been using Kobos for years I didn't bother with kepubs at all until I got my KA1. Once I decided to give them a try it became clear how different they are when it comes to style issues (monospace, sans-serif, small-caps, hyphenation, ligatures and footnotes).

For kepubs, styling as monospace is actually easier in some ways than it is for epubs because all that's required is to change the CSS from font-family:monospace to font-family:"Courier New" (if "Courier New" is your chosen sideloaded monospace font) rather than needing to add @font-face statements. The obvious problem being that this requires manually editing every book which uses monospace.

This would be time-consuming but, worse than that, making these changes to your master epub in calibre would almost certainly be counter-productive if you also want to send the master epub to a different device, e.g. Android, or even if you change your mind and decide that standard epubs are preferable for the Kobo.

I did solve this conundrum for myself by customising my personal copy of the KoboTouchExtended plugin driver to make the necessary CSS changes on-the-fly during the calibre send-to-device process. This is obviously not an option for everyone but if you have some Python coding skills it's possible to do all sorts of interesting (OK, I'm a nerd ) stuff on-the-fly. Should you ever choose to go down this route feel free to PM me. I'm happy to share anything you'd find useful.

Python is not one of my stronger languages (I'm more a Java girl), but editing the plugin driver does sound like something I could manage! I will PM you, and would love to hear more about what you did with this!
TuxGirl is offline   Reply With Quote
Old 05-03-2017, 01:21 PM   #9
TuxGirl
Groupie
TuxGirl can grip it by the huskTuxGirl can grip it by the huskTuxGirl can grip it by the huskTuxGirl can grip it by the huskTuxGirl can grip it by the huskTuxGirl can grip it by the huskTuxGirl can grip it by the huskTuxGirl can grip it by the huskTuxGirl can grip it by the huskTuxGirl can grip it by the huskTuxGirl can grip it by the husk
 
Posts: 178
Karma: 141378
Join Date: Sep 2009
Device: kindle
Quote:
Originally Posted by GeoffR View Post
The KePub reader uses the default sans-serif font (Avenir) when you specify font-family:monospace; in the stylesheet. The trick with the ePub reader was to define "monospace" as the name of a monospace font you have installed, but I'm not sure whether that works for the KePub reader. From what you describe it sounds like it doesn't.

In that case you would need to edit the stylesheet in the book to change every instance of font-family:monospace; to font-family:"Courier New",monospace; to use your installed Courier New font as the monospace font. If the book uses <pre> tags for code then you'd also need to set pre {font-family:"Courier New",monospace;} in the stylesheet. That is a lot more work than for ePubs.

Edit: There is also a shorthand form: font: that some books use instead of font-family:. That would need to be changed too.

(I read some KePubs synced from the Kobo server, but I always sideload ePubs because the ePub reader does this typographical stuff much better than the KePub reader.)

The font selection menu showing Italics was a change in one of the recent firmware updates.

Geoff: Thanks for answering. I will look at playing with this and getting this type of setup working for at least one book, then may look at doing something similar to what jackie_w did to code it up in the driver.

Thanks!
TuxGirl is offline   Reply With Quote
Reply

Thread Tools Search this Thread
Search this Thread:

Advanced Search

Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
Smaller monospace font? Action Superhero Kindle Formats 1 03-30-2016 11:27 AM
HTML to ePUB with monospace font il_mix Conversion 12 06-28-2013 10:07 AM
* to Mobi: setting monospace font size Starko Conversion 7 11-16-2012 03:04 PM
Getting word breaks to work correctly Techno4 ePub 1 08-27-2012 01:27 PM
DOC format does not work correctly greenapple iRiver Story 10 05-16-2010 11:00 PM


All times are GMT -4. The time now is 10:23 AM.


MobileRead.com is a privately owned, operated and funded community.