-
Notifications
You must be signed in to change notification settings - Fork 5.9k
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
Fixes font-subset to not drop GSUB/GPOS/GDEF tables for variable fonts where they are needed Fixes #125704 #41592
Conversation
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 (don't just cc him here, he won't see it! He's on Discord!). If you are not sure if you need tests, consider this rule of thumb: the purpose of a test is to make sure someone doesn't accidentally revert the fix. Ask yourself, is there anything in your PR that you feel it is important we not accidentally revert back to how it was before your fix? Reviewers: Read the Tree Hygiene page and make sure this patch meets those guidelines before LGTMing. |
I have now added tests to the PR. All tests that are performed on the existing (non variable) test font are now repeated on a variable font. This variable font is a smaller subset of the Material Symbols icon outlined font. The supplied golden fonts ( All tests were verified to pass. |
tools/font-subset/main.cc
Outdated
@@ -83,7 +87,7 @@ int main(int argc, char** argv) { | |||
|
|||
HarfbuzzWrappers::HbBlobPtr font_blob( | |||
hb_blob_create_from_file(input_file_path.c_str())); | |||
if (!hb_blob_get_length(font_blob.get())) { | |||
if (!hb_blob_get_length(font_blob.get())) {cd |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
if (!hb_blob_get_length(font_blob.get())) {cd | |
if (!hb_blob_get_length(font_blob.get())) { |
Fixed. Embarrassing! I apologize for that careless typo - I remember that unexpected request to save that file now.. I am usually more careful than that I promise ;) edit: post mortem - That accidently snuck in when I was adding the test.py commit with the tests. |
CI is complaining about formatting issues. When I build and run this locally on an arm64 mac, some of the tests are failing. They also fail with your code changes commented out. |
I saw the complaint about formatting - I checked for any hidden tab chars or trailing spaces and did not find any. I tried to format things as the existing code is formatted.. Is there a formatting tool that can be used on the .cc files ? I am running the test locally on my windows machine. The mac CI tests seem to be passing? The added if statement should only change the previous behavior when there is both variable font tables found within the font, and these tables contain variable axes definitions. This should prevent it from doing anything in any fonts that may have 'empty' variable font tables included. In all other cases the output should be identical (ie any GSUB/GPOS/GDEF tables will be dropped in the output font). |
Our development workflows on Windows aren't great. I ran the format script for you locally. I'll try to figure out why the tests are complaining so much for me. Also it seems like I may have made things unhappy in the git history, which I'll try to fix. |
…t with variable font axes before additionally dropping the GSUB/GPOS/GDEF tables. These tables were being forced dropped in all cases (even though harfbuzz had been modified to always keep them). I made the change only drop the tables for variable fonts to preserve the previous behavior in the most possible cases. This PR fixes #125704. To see the bug (or verify it is fixed) in the live web examples below you must select the font variations Fill->1 and Weight->100. (See issue #125704 for more details). The issue #125704 includes examples of the font-subset being used (and breaking) the variable fonts, as well as example of the --no-tree-shake-icons being used where the fonts do not break. Additionally, I have created an additional live example where this PR has been applied to font-subset and icon tree shaking is still taking place. (Example w/ icon tree-shaking using the broken font-subset for icon tree shaking is found here ). In the example build output below note that the non-variable fonts "CupertinoIcons.ttf" and "MaterialIcons-Regular.otf" have the same size savings as before the change, but the variable fonts "MaterialSymbolsSharp[FILL,GRAD,opsz,wght].ttf", "MaterialSymbolsOutlined[FILL,GRAD,opsz,wght].ttf", and "MaterialSymbolsRounded[FILL,GRAD,opsz,wght].ttf" now have a much more reasonable saving of ~2% because every icon in the font is included in the example. The previous extra ~30% savings was from having the GSUB table removed. The 30% size savings for a tree-shaking for a case where every icon is used in the example probably should have been suspect.
Thanks for formatting - I just rebased to what you ended up with. |
Tests build and run as expected on Linux (and apparently Windows), but not mac. |
Ok, it looks like they're passing on Intel Mac but maybe not ARM. Looking to see if CI is running arm somewhere... |
The 3variable.ttf seems to not have a GSUB table... |
investigating... |
no - sorry mistake on my part - not corrupted. |
Argh. I think this is an error on my end. |
I was building the |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM
ok great! |
…iable fonts where they are needed Fixes flutter#125704 (flutter/engine#41592)
…125839) flutter/engine@58cc541...3fa6084 2023-05-01 timmaffett@gmail.com Fixes font-subset to not drop GSUB/GPOS/GDEF tables for variable fonts where they are needed Fixes #125704 (flutter/engine#41592) 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 jsimmons@google.com,rmistry@google.com,zra@google.com on the revert to ensure that a human is aware of the problem. To file a bug in Flutter: https://github.com/flutter/flutter/issues/new/choose 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/+doc/main/autoroll/README.md
This PR fixes font-subset to check to see if a font is a variable font with variable font axes before additionally dropping the GSUB/GPOS/GDEF tables. These tables were being forced dropped in all cases (even though harfbuzz had been modified to always keep them). I made the change only drop the tables for variable fonts to preserve the previous behavior in the most possible cases.
This PR fixes #125704.
To see the bug (or verify it is fixed) in the live web examples below you must select the font variations Fill->1 and Weight->100.
(See issue #125704 for more details).
The issue #125704 includes examples of the font-subset being used (and breaking) the variable fonts, as well as example of the
--no-tree-shake-icons
being used where the fonts do not break.Additionally, I have created an additional live example where this PR has been applied to font-subset and icon tree shaking is still taking place.
(Example w/ icon tree-shaking using the broken font-subset for icon tree shaking is found here ).
In the example build output below note that the non-variable fonts "CupertinoIcons.ttf" and "MaterialIcons-Regular.otf" have the same size savings as before the change, but the variable fonts "MaterialSymbolsSharp[FILL,GRAD,opsz,wght].ttf", "MaterialSymbolsOutlined[FILL,GRAD,opsz,wght].ttf", and "MaterialSymbolsRounded[FILL,GRAD,opsz,wght].ttf" now have a much more reasonable saving of ~2% because every icon in the font is included in the example. The previous extra ~30% savings was from having the GSUB table removed. The 30% size savings for a tree-shaking for a case where every icon is used in the example probably should have been suspect.. lol.
Output of build using fixed font-subset.exe live fix example :
BEFORE font-subset fix live bug example here:
Pre-launch Checklist
///
).If you need help, consider asking for advice on the #hackers-new channel on Discord.