thorium-reader icon indicating copy to clipboard operation
thorium-reader copied to clipboard

EPUB: monospace rendering for code examples

Open weiss-d opened this issue 4 years ago • 4 comments

Reading some programming books in EPUB format, I thought it would be cool to render code snippets, that are styled in CSS accordingly, in monospace font.

Annotation 2020-06-29 103043

weiss-d avatar Jun 29 '20 07:06 weiss-d

Hello, I am not able to reproduce this problem with the default user settings, which do not override the authored font faces. However, as a user if I choose to override the publisher styles with a custom font, then this is applied to all text, including the monospace code sections. @JayPanoz this sounds like something that is controlled by https://github.com/readium/readium-css right?

danielweck avatar Jun 29 '20 21:06 danielweck

@danielweck, sorry, looks like I have instinctively switched the font because default one looks so Windows9x-ish and it's hard to read, I honestly don't remember when I did this 🙄 And default monospace is almost disappearing on 1920x1080 display. It wood be so cool if it could override fonts by category, e.g. 'Humanist' for sans serif, 'Monospace' for monospace etc.

image

weiss-d avatar Jun 30 '20 04:06 weiss-d

this sounds like something that is controlled by https://github.com/readium/readium-css right?

Indeed but we’re only applying font-family to a subset of HTML elements, which doesn’t contain markup elements for code, etc.

So it seems to me the user setting is applied to code because it’s using p class in this publication. If the markup in the book was using pre + code it shouldn’t have been overridden.

That said, it wouldn’t solve this rendering issue raised by @weiss-d

And default monospace is almost disappearing on 1920x1080 display. It wood be so cool if it could override fonts by category, e.g. 'Humanist' for sans serif, 'Monospace' for monospace etc.

That’s quite tricky with CSS only since emulating defaults (for sans-serif, serif, monospace, script, etc.) is not really a thing it was meant for. It’s more of an app concern as they have easier access to that (+ installed fonts) and then there’s the issue of force-overriding the authors’ stylesheets (cf. browsers).

Capture d’écran 2020-06-30 à 10 49 21

But I can imagine Electron has something for that?

JayPanoz avatar Jun 30 '20 08:06 JayPanoz

It seems I have a similar problem: I read books that contain code snippets in a monospace font. In order to still be able to read something, I have to greatly enlarge the font, but the code display remains very small in places. Also, the contrast in these areas is too weak. Changing the font and size in the settings does not change anything.

image

(Thorium-Reader on Windows 10, epub)

Even though I can read the "normal" text with the screen reader, it is better understanding to read the code examples myself.

Helpful would be therefore:

  • a possibility to increase the font size of code examples.
  • a better contrast for the areas

But otherwise this is a really nice program, thanks!

henrietteBaum avatar Aug 13 '21 09:08 henrietteBaum

Moving to https://github.com/readium/readium-css/issues/112

danielweck avatar Aug 26 '22 18:08 danielweck