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

Pass LinearTextFlag to SkFont - iOS13 letter spacing#13321

Merged
GaryQian merged 3 commits intoflutter:masterfrom
GaryQian:ios13font
Oct 28, 2019
Merged

Pass LinearTextFlag to SkFont - iOS13 letter spacing#13321
GaryQian merged 3 commits intoflutter:masterfrom
GaryQian:ios13font

Conversation

@GaryQian
Copy link
Contributor

Call hb_font_set_funcs again since harfbuzz is now modern.

This fixes flutter/flutter#41101

@GaryQian
Copy link
Contributor Author

Actually, this is WIP. This breaks tons of txt_unittests by a tiny subpixel amount. Need to verify if this is ok. cc @Rusino Heads up!

This fix is quite important though as without it, iOS 13 is very ugly.

@GaryQian GaryQian added the Work in progress (WIP) Not ready (yet) for review! label Oct 24, 2019
@GaryQian
Copy link
Contributor Author

It is possible this may also require goldens/scuba updates if the changes are acceptable.

@GaryQian
Copy link
Contributor Author

After reviewing the layout results, it seems this would introduce regressions in many cases and hb_font_set_funcs cannot be generally reapplied.

Will explore more specific or alternative solutions.

@GaryQian
Copy link
Contributor Author

Modified to pass the LinearTextFlag to SkFont. Will need to verify this works as expected and maintains fixing ios13.

MinikinPaint* paint = reinterpret_cast<MinikinPaint*>(fontData);
float advance = paint->font->GetHorizontalAdvance(glyph, *paint);
return 256 * advance + 0.5;
return 256 * advance;
Copy link
Contributor Author

Choose a reason for hiding this comment

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

I could not figure out why there is a + 0.5. I have removed it. This constant seems to have no positive effect on the layout and would break a large suite of tests for no discernible reason.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I will be putting the 0.5 back in, as the framework tests/goldens will fully pass with this constant addition. This may be to mirror harfbuzz's implementation. In any case, with the + 0.5, we no longer need to manually roll, though it will require many more small adjustments throughout txt_unittests

Copy link
Contributor Author

Choose a reason for hiding this comment

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

the 0.5 was to make the rounding round both up and down instead of flooring

@GaryQian
Copy link
Contributor Author

Passing LinearTextFlag causes the if statement in Skia SkFontHost_FreeType.cpp:1292 to trigger and produce the non-rounded version of the advance. We want to use the full advance because we do not use the advance directly, but rather as a metric.

@GaryQian GaryQian changed the title Fix iOS13 letter spacing bug Pass LinearTextFlat to SkFont - iOS13 letter spacing Oct 25, 2019
@GaryQian
Copy link
Contributor Author

This will require a manual engine roll due to sub-pixel differences in the text framework tests.

@GaryQian
Copy link
Contributor Author

Confirmed this fixes iOS 13 letter spacing bug and handles bold properly.

@GaryQian
Copy link
Contributor Author

This no longer needs a manual roll.

@GaryQian GaryQian merged commit 728e473 into flutter:master Oct 28, 2019
@GaryQian GaryQian changed the title Pass LinearTextFlat to SkFont - iOS13 letter spacing Pass LinearTextFlag to SkFont - iOS13 letter spacing Oct 28, 2019
engine-flutter-autoroll added a commit to engine-flutter-autoroll/flutter that referenced this pull request Oct 28, 2019
engine-flutter-autoroll added a commit to engine-flutter-autoroll/flutter that referenced this pull request Oct 28, 2019
@GaryQian GaryQian removed the Work in progress (WIP) Not ready (yet) for review! label Oct 28, 2019
engine-flutter-autoroll added a commit to flutter/flutter that referenced this pull request Oct 28, 2019
[email protected]:flutter/engine.git/compare/869b74eb4eca...728e473

git log 869b74e..728e473 --no-merges --oneline
2019-10-28 [email protected] Pass LinearTextFlat to SkFont -  iOS13 letter spacing (flutter/engine#13321)
2019-10-28 [email protected] Roll src/third_party/skia 428b5de64a08..18f5b1a6dd77 (1 commits) (flutter/engine#13387)


If this roll has caused a breakage, revert this CL and stop the roller
using the controls here:
https://autoroll.skia.org/r/flutter-engine-flutter-autoroll
Please CC [email protected] on the revert to ensure that a human
is aware of the problem.

To report a problem with the AutoRoller itself, please file a bug:
https://bugs.chromium.org/p/skia/issues/entry?template=Autoroller+Bug

Documentation for the AutoRoller is here:
https://skia.googlesource.com/buildbot/+/master/autoroll/README.md
Inconnu08 pushed a commit to Inconnu08/flutter that referenced this pull request Nov 26, 2019
[email protected]:flutter/engine.git/compare/869b74eb4eca...728e473

git log 869b74e..728e473 --no-merges --oneline
2019-10-28 [email protected] Pass LinearTextFlat to SkFont -  iOS13 letter spacing (flutter/engine#13321)
2019-10-28 [email protected] Roll src/third_party/skia 428b5de64a08..18f5b1a6dd77 (1 commits) (flutter/engine#13387)


If this roll has caused a breakage, revert this CL and stop the roller
using the controls here:
https://autoroll.skia.org/r/flutter-engine-flutter-autoroll
Please CC [email protected] on the revert to ensure that a human
is aware of the problem.

To report a problem with the AutoRoller itself, please file a bug:
https://bugs.chromium.org/p/skia/issues/entry?template=Autoroller+Bug

Documentation for the AutoRoller is here:
https://skia.googlesource.com/buildbot/+/master/autoroll/README.md
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.

Font Changes in iOS 13.0 and Flutter 1.9

3 participants