Skip to content
This repository was archived by the owner on Feb 25, 2025. It is now read-only.

Conversation

@jason-simmons
Copy link
Member

When Minikin searches for a font based on a font style, it will score the fonts
in the family and choose the best match. However, multiple fonts may have
equal scores (e.g. searching for a font with weight 600 when the set includes
fonts with weights 500 and 700). In this case Minikin will select the first
font in the list with the best score.

However, the fonts in a font family's SkFontStyleSet may not always be provided
in a consistent order by the SkFontMgr. So if the minikin::FontFamily list is
populated based on the SkFontStyleSet order, then a query for a given style might
not always return the same font.

This change sorts the typefaces in the SkFontStyleSet before converting them
into a Minikin font family.

Fixes flutter/flutter#31212

When Minikin searches for a font based on a font style, it will score the fonts
in the family and choose the best match.  However, multiple fonts may have
equal scores (e.g. searching for a font with weight 600 when the set includes
fonts with weights 500 and 700).  In this case Minikin will select the first
font in the list with the best score.

However, the fonts in a font family's SkFontStyleSet may not always be provided
in a consistent order by the SkFontMgr.  So if the minikin::FontFamily list is
populated based on the SkFontStyleSet order, then a query for a given style might
not always return the same font.

This change sorts the typefaces in the SkFontStyleSet before converting them
into a Minikin font family.

Fixes flutter/flutter#31212
SkFontStyle b_style = b->fontStyle();
return (a_style.weight() != b_style.weight())
? a_style.weight() < b_style.weight()
: a_style.slant() < b_style.slant();
Copy link
Contributor

Choose a reason for hiding this comment

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

Is the slant always different? Is it possible to have a pair of fonts with identical weight and slant?

Copy link
Member Author

Choose a reason for hiding this comment

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

Typically a font family would not include multiple fonts with the same weight and slant, but there is no guarantee against that

Copy link
Contributor

@GaryQian GaryQian left a comment

Choose a reason for hiding this comment

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

LGTM, up to you if you want to do further comparison for edge cases/adversarial font families

@GaryQian
Copy link
Contributor

Oh, could you add a test for this case?

@jason-simmons jason-simmons merged commit dd0eecc into flutter:master Aug 16, 2019
engine-flutter-autoroll added a commit to engine-flutter-autoroll/flutter that referenced this pull request Aug 16, 2019
engine-flutter-autoroll added a commit to flutter/flutter that referenced this pull request Aug 17, 2019
[email protected]:flutter/engine.git/compare/e5f9132b347c...4d5c38e

git log e5f9132..4d5c38e --no-merges --oneline
2019-08-16 [email protected] Roll src/third_party/dart a3b579d5c3..2a3b844b41 (5 commits) (flutter/engine#11060)
2019-08-16 [email protected] Roll src/third_party/skia df54f37a5dc1..237a95fe7b28 (2 commits) (flutter/engine#11058)
2019-08-16 [email protected] Roll buildroot to 5a33d6a to pickup changes to toolchain version tracking. (flutter/engine#11061)
2019-08-16 [email protected] Sort the Skia typefaces in a font style set into a consistent order (flutter/engine#11056)
2019-08-16 [email protected] Add ccls config files to .gitignore (flutter/engine#11046)
2019-08-16 [email protected] Pass Android Q insets.systemGestureInsets to Window (flutter/engine#10413)

The AutoRoll server is located here: https://autoroll.skia.org/r/flutter-engine-flutter-autoroll

Documentation for the AutoRoller is here:
https://skia.googlesource.com/buildbot/+/master/autoroll/README.md

If the roll is causing failures, please contact the current sheriff ([email protected]), and stop
the roller if necessary.
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Using a font with an unsupported font weight leads to flaky behavior

3 participants