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

Fonts: fix font scoring and Harfbuzz measurements #578

Merged
merged 2 commits into from
Jul 21, 2024

Conversation

poire-z
Copy link
Contributor

@poire-z poire-z commented Jul 20, 2024

LVFontDef::CalcMatch(): bump weight of typeface match

When checking "font-family: SomeFont, serif" and requesting italic or bold, the serif font could win even if SomeFont is present, if SomeFont has no real italic of bold variant, but the serif font has them.
So, stop iterating the provided names list early when a typeface matches.
Noticed at #572 (comment), see followup posts.

Font: fix measureText() when max_width met with fallback font

When using Harfbuzz, if we would meet max_width (32767px) while measuring text with a fallback font, we would return a too large lastFitChar, and invalid measurements for the chars between the real lastFitChar and the one returned, possibly resulting in chars overlapping previous ones and garbled text rendering.
See koreader/koreader#12183 (comment).
Should allow closing koreader/koreader#12183.


This change is Reviewable

poire-z added 2 commits July 20, 2024 20:07
When checking "font-family: SomeFont, serif" and requesting
italic or bold, the serif font could win even if SomeFont
is present, if SomeFont has no real italic of bold variant,
but the serif font has them.
So, stop iterating the provided names list early when
a typeface matches.
When using Harfbuzz, if we would meet max_width (32767px)
while measuring text with a fallback font, we would return
a too large lastFitChar, and invalid measurements for
the chars between the real lastFitChar and the one returned,
possibly resulting in chars overlapping previous ones and
garbled text rendering.
Copy link
Member

@Frenzie Frenzie left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Trusting you, it'd take a while to read into the logic ^_^

@poire-z poire-z merged commit 3410e24 into koreader:master Jul 21, 2024
1 check passed
@poire-z poire-z deleted the lvfntman_fixes branch July 21, 2024 16:02
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.

2 participants