You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
When a text consists of a mix of two different font files, for example a overly aggressive subset and an original font fallback for a few glyphs, the font metrics across the boundary of the glyphs from different files are wrong. This is because kerning pairs, ligatures and possibly other font tables cannot apply at these boundaries.
This means that in the worst case scenario where a subfont subset and an original font fallback are both in play, any typographer would become very unhappy.
A solution to keeping the intended font metrics could be to disable the subfont subset when we detect that the original font has been loaded. This can be achieved by using the CSS font loading API to observe when the original font loads, then remove the subfont subset font-face rule from the stylesheet.
Fill in default values for empty strings in Css style rules
Set CssFontFamilyRule src url to be the original fonts url. This is to avoid the font matching algorithm matching a different __subset font and synthesising the one we just disabled
Re-resolve href to original font url from where the subset font declaration resides. Possibly save this in a non-standard -subfont-original-src property at build time
What if the original @font-face-declarations don't reside in the HTML, but in an external CSS file? Maybe we can move the declarations next to the subfont generated ones at build time
If we save the original font-face blocks src property as -subfont-src in the subset font-face block, then we only need to compare that property and can maybe skip font-family unquoting, font-weight normalization, default fallbacks
When a text consists of a mix of two different font files, for example a overly aggressive subset and an original font fallback for a few glyphs, the font metrics across the boundary of the glyphs from different files are wrong. This is because kerning pairs, ligatures and possibly other font tables cannot apply at these boundaries.
This means that in the worst case scenario where a subfont subset and an original font fallback are both in play, any typographer would become very unhappy.
A solution to keeping the intended font metrics could be to disable the subfont subset when we detect that the original font has been loaded. This can be achieved by using the CSS font loading API to observe when the original font loads, then remove the subfont subset font-face rule from the stylesheet.
Example implementation:
Tested in
Replaces #33
TODOs
src
url to be the original fonts url. This is to avoid the font matching algorithm matching a different__subset
font and synthesising the one we just disabled-subfont-original-src
property at build time@font-face
-declarations don't reside in the HTML, but in an external CSS file? Maybe we can move the declarations next to the subfont generated ones at build timeExample repository to iterate on and test in different browsers: https://github.com/Munter/font-subset-delete-POC
Deployed at https://font-subset-delete.netlify.com/
The text was updated successfully, but these errors were encountered: