Open Munter opened 6 years ago
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
Can we have a status update on this one?
Status is that this issue is mostly a brain dump from a collaboration session and no further work has gone into it.
It would be great to have the remaining browsers tested. If they all work I think the task can be considered ready for development
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/