koreader / crengine

This is the KOReader CREngine fork. It cross-pollinates with the official CoolReader repository at https://github.com/buggins/coolreader, in case you were looking for that one.
70 stars 45 forks source link

Fonts: fix font scoring and Harfbuzz measurements #578

Closed poire-z closed 1 month ago

poire-z commented 1 month ago

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 https://github.com/koreader/crengine/pull/572#issuecomment-2195504556, 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 https://github.com/koreader/koreader/issues/12183#issuecomment-2240950279. Should allow closing https://github.com/koreader/koreader/issues/12183.


This change is Reviewable