Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Monospace and fallback fonts tweaks #486

Merged
merged 7 commits into from Jul 17, 2022

Conversation

poire-z
Copy link
Contributor

@poire-z poire-z commented Jul 16, 2022

Text: fix possible overflow with "white-space: pre"

Since #454, text in PRE could overflow the PRE width. Fix that.
image

Fonts: getFontFileNameAndFaceIndex(): return family type

As crengine/FreeType can't distinguish sans serif from serif, this is only useful to detect if a font is monospace or not. Might be useful for frontends.
See koreader/koreader#9211 (comment).

Fonts: account for _bias in Font hash

Should trigger a rerendering when we change the bias of some fonts.
Also fix GetFontListHash() which was always returning 0 since ages...

epub.css, fb2.css: remove hardcoded monospace font names

This should allow another monospace font, set with a bias, to be used for <pre> and <code> (as with anything having font-family: monospace).

Fonts: allow scaling monospace fonts

So that when using a main font with a small x-height, one can avoid having tall inline <code> bits, and adjust them (manually) to fit the size of the main font or to be a bit smaller to help distinguishing them.
image

See koreader/koreader#9211.

Fonts: allow adjusting fallback font sizes to x-height

Having all fallback font size having the same x-height should make lowercase letters picked from them less noticable (this can be noticable with greek words, as latin fonts often have only a subset of greek letters, related to maths).
See koreader/koreader#9211 (comment).

HTML parser: trust xml encoding before html charset

EPUBs can have both, and it seems that doing it per XHTML specs is the right thing to do.
See koreader/koreader#8306 (comment) , https://www.w3.org/TR/xhtml1/#C_9


With all this, KOReader will get 2 new menu items in Font settings>:
image


This change is Reviewable

As crengine/FreeType can't distinguish sans serif
from serif, this is only useful to detect if a font
is monospace or not. Might be useful for frontends.
Should trigger a rerendering when we change the
bias of some fonts.
Also fix GetFontListHash() which was always
returning 0 since ages...
This should allow another monospace font, set with a bias,
to be used for <pre> and <code> (as with anything having
"font-family: monospace").
So that when using a main font with a small x-height,
one can avoid having tall inline <code> bits, and
adjust them (manually) to fit the size of the main font
or to be a bit smaller to help distinguishing them.
Having all fallback font size having the same x-height
should make lowercase letters picked from them less
noticable (this can be noticable with greek words,
as latin fonts often have only a subset of greek
letters, related to maths).
EPUBs can have both, and it seems that doing it
per XHTML specs is the right thing to do.
@Frenzie
Copy link
Member

Frenzie commented Jul 17, 2022

It's not quite clear to me if what's true for XHTML is true for XHTML5 btw.
https://html.spec.whatwg.org/multipage/xhtml.html

@poire-z
Copy link
Contributor Author

poire-z commented Jul 17, 2022

Well, I guess we'll see with time if it was a bad decision, and if we need to make this toggable.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants