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

Comparing changes

Choose two branches to see what’s changed or to start a new pull request. If you need to, you can also or learn more about diff comparisons.

Open a pull request

Create a new pull request by comparing changes across two branches. If you need to, you can also . Learn more about diff comparisons here.
base repository: flutter/engine
Failed to load repositories. Confirm that selected base ref is valid, then try again.
Loading
base: 58cc54197a54
Choose a base ref
...
head repository: flutter/engine
Failed to load repositories. Confirm that selected head ref is valid, then try again.
Loading
compare: 3fa6084dfb36
Choose a head ref
  • 1 commit
  • 6 files changed
  • 1 contributor

Commits on May 1, 2023

  1. Fixes font-subset to not drop GSUB/GPOS/GDEF tables for variable font…

    …s where they are needed Fixes #125704 (#41592)
    
    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](flutter/flutter#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](flutter/flutter#125704)
    for more details).
    
    The issue [#125704](flutter/flutter#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](https://timmaffett.github.io/material_symbols_icons_showing_tree_shake_fixed/)
    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](https://timmaffett.github.io/material_symbols_icons_showing_tree_shake_bug/)
    ).
    
    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](https://timmaffett.github.io/material_symbols_icons_showing_tree_shake_fixed/)
    :
    ```console
    flutter build web --release --web-renderer canvaskit --base-href "/material_symbols_icons_showing_tree_shake_fixed/"
    
    Font asset "CupertinoIcons.ttf" was tree-shaken, reducing it from 283452 to 1236 bytes (99.6% reduction). Tree-shaking can be disabled by providing the
    --no-tree-shake-icons flag when building your app.
    Font asset "MaterialIcons-Regular.otf" was tree-shaken, reducing it from 1645184 to 10808 bytes (99.3% reduction). Tree-shaking can be disabled by providing the
    --no-tree-shake-icons flag when building your app.
    Font asset "MaterialSymbolsSharp[FILL,GRAD,opsz,wght].ttf" was tree-shaken, reducing it from 5848492 to 5683212 bytes (2.8% reduction). Tree-shaking can be disabled by
    providing the --no-tree-shake-icons flag when building your app.
    Font asset "MaterialSymbolsOutlined[FILL,GRAD,opsz,wght].ttf" was tree-shaken, reducing it from 6944756 to 6779476 bytes (2.4% reduction). Tree-shaking can be disabled
    by providing the --no-tree-shake-icons flag when building your app.
    Font asset "MaterialSymbolsRounded[FILL,GRAD,opsz,wght].ttf" was tree-shaken, reducing it from 9361824 to 9196544 bytes (1.8% reduction). Tree-shaking can be disabled
    by providing the --no-tree-shake-icons flag when building your app.
    Compiling lib\main.dart for the Web...                             79.5s
    ```
    
    BEFORE font-subset fix [live bug example
    here](https://timmaffett.github.io/material_symbols_icons_showing_tree_shake_bug/):
    ```console
    flutter build web --release --web-renderer canvaskit --base-href "/material_symbols_icons_showing_tree_shake_bug/"
    
    Font asset "CupertinoIcons.ttf" was tree-shaken, reducing it from 283452 to 1236 bytes (99.6% reduction). Tree-shaking
    can be disabled by providing the --no-tree-shake-icons flag when building your app.
    Font asset "MaterialSymbolsSharp[FILL,GRAD,opsz,wght].ttf" was tree-shaken, reducing it from 5848492 to 4079548 bytes
    (30.2% reduction). Tree-shaking can be disabled by providing the --no-tree-shake-icons flag when building your app.
    Font asset "MaterialSymbolsOutlined[FILL,GRAD,opsz,wght].ttf" was tree-shaken, reducing it from 6944756 to 4781576 bytes(31.1% reduction). Tree-shaking can be disabled by providing the --no-tree-shake-icons flag when building your app.
    Font asset "MaterialIcons-Regular.otf" was tree-shaken, reducing it from 1645184 to 10808 bytes (99.3% reduction).
    Tree-shaking can be disabled by providing the --no-tree-shake-icons flag when building your app.
    Font asset "MaterialSymbolsRounded[FILL,GRAD,opsz,wght].ttf" was tree-shaken, reducing it from 9361824 to 6397020 bytes
    (31.7% reduction). Tree-shaking can be disabled by providing the --no-tree-shake-icons flag when building your app.
    Compiling lib\main.dart for the Web...                             63.8s
    ```
    timmaffett authored May 1, 2023
    Configuration menu
    Copy the full SHA
    3fa6084 View commit details
    Browse the repository at this point in the history
Loading