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

Conversation

xster
Copy link
Member

@xster xster commented Aug 17, 2020

Fixes flutter/flutter#60013
The problem turned out way simpler than I expected. Despite it being officially deprecated, searching for font by font family name string is still working on iOS 14. We still have to fix it at some point but for now, the thing that got borked was searching for the broad family name such as .AppleSystemUIFont/.SFUI-Regular actually returns both condensed and normal widths of the fonts (the kCTFontWidthTrait). We weren't accounting for it in our sorting so we can end up with the narrower font.

Didn't write tests yet. Would love a pointer for which file this might fit in (or whether I'd have to start something new)

@flutter-dashboard
Copy link

It looks like this pull request may not have tests. Please make sure to add tests before merging. If you need an exemption to this rule, contact Hixie on the #hackers channel in Chat.

Reviewers: Read the Tree Hygiene page and make sure this patch meets those guidelines before LGTMing.

@xster
Copy link
Member Author

xster commented Aug 17, 2020

Screen Shot 2020-08-17 at 11 36 24 AM

@dnfield
Copy link
Contributor

dnfield commented Aug 17, 2020

Can we add a golden test on a simulator for this?

I don't think we can run a 14.0 simulator on CI, but at least we can catch if the text regresses.

@xster
Copy link
Member Author

xster commented Aug 18, 2020

I'm gonna wait a few days on this for https://skia-review.googlesource.com/c/skia/+/311596 to go through so I can test.

@xster xster force-pushed the ios-14-font-sorting branch from 0b230e7 to 9fced26 Compare August 21, 2020 06:24
@xster
Copy link
Member Author

xster commented Aug 21, 2020

Ok, Skia patch is in. Added some tests.

@dnfield yes and no. Yes because we already have a golden test which should fail once we move the CI to iOS 14. (Food for thought for @jmagman. This might be our opening gambit for future go/flutter-apple-release-cadence to flush these out). No because those tests should be in the framework since there is no public API here flutter.dev/go/flutter-skia-ios-font-problem.

@xster
Copy link
Member Author

xster commented Aug 21, 2020

lol, at a quick glance, it seems like we may not have a single non-ahem golden test in https://flutter-gold.skia.org/list.

Actually I just thought there might one thing we can do, somewhat tangentially to this PR. We can test in a scenario test that when you ask for a bogus font on iOS, it should always draw in SF. I'll send a separate PR.

@xster xster requested a review from jason-simmons August 21, 2020 06:36
@xster
Copy link
Member Author

xster commented Aug 21, 2020

Beh, I didn't feel like writing perf. Here's the test #20687. It'll fail until this one's merged.

@xster
Copy link
Member Author

xster commented Aug 21, 2020

Actually that one probably won't fail since we're not running on iOS 14. Both can merge independently.

// Flutter APIs have the weight specified to narrow it down
// later. The width ordering here is more consequential since
// TextStyle doesn't have letter width APIs.
return std::abs(a_style.width() - SkFontStyle::kNormal_Width) <
Copy link
Member

Choose a reason for hiding this comment

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

Is it possible for a_style.width() to be kNormal_Width - delta and b_style.width() to be kNormal_Width + delta?

If so, then add something that prefers either a or b in that case in order to ensure consistency in the sort results.

Minikin's FontCollection will choose the first font in the list among the fonts that have the highest value in Minikin's scoring algorithm. The sort should ensure that the first such font is always the same in each run of the app.

Copy link
Member Author

Choose a reason for hiding this comment

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

Did you mean 2 widths equidistant from the middle in opposite directions? Ya, very good point. We can make that case deterministic.

Copy link
Member Author

Choose a reason for hiding this comment

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

done

@xster xster force-pushed the ios-14-font-sorting branch from 053ae74 to 6959e74 Compare August 24, 2020 16:09
@xster xster requested a review from jason-simmons August 24, 2020 16:10
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.

[iOS] Some text is displaying incorrectly on iOS 14

4 participants