⚡️ feat(fonts): optimise font size #186
Merged
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Summary
This PR significantly reduces font file sizes while maintaining key typographic features and maintaining most language support. It impacts all tabi fonts: Cascadia Code, Inter, and Source Serif 4 fonts.
Related issue: #174.
Changes
Cascadia Code: Format Retained, Subsetted to Basic ASCII and Ligatures
pyftsubset CascadiaCode-SemiLight.woff2 \ --layout-features="kern,liga" \ --desubroutinize \ --unicodes=U+0020-007E,U+00A0-00FF \ --flavor=woff2 \ --output-file=font_with_accents.woff2
Inter: Updated to Latest Version, Subsetted for Broad Language Support
Source Serif 4: Moved to OTF, Subsetted for Broad Language Support
Benefits
Custom Optimisation
If the provided font subsets don't cover your particular needs—say, you require characters from a specific script like Devanagari or you're sure you won't use any non-English characters—you can easily create your own subsets.
Steps
Download the Font: Download the full WOFF2 or OTF font file from the respective repository or official website.
Run the
pyftsubset
Command: Use thepyftsubset
command to specify the range of characters, layout features, and other options. Place the resulting file in yourstatic/fonts/
directory (not the theme's directory). The new file will load, instead of the theme's.Or, if you'll only write in English, perhaps a smaller subset with punctuation, currency and some symbols would suffice:
pyftsubset CascadiaCode-SemiLight.woff2 \ --layout-features="kern,liga" \ --desubroutinize \ --unicodes=U+0020-007E,U+00A0-00FF,U+2000-206F,U+20A0-20CF,U+2100-214F \ --flavor=woff2 \ --output-file=font_with_extended_characters.woff2
Note: replace
YourFont.woff2
andyour_custom_font.woff2
with the relevant file names. The name of the file you place on yourstatic/fonts
directory must match the of the file you're "overwriting" (e.g.SourceSerif4Variable-Roman.otf.woff2
orInter4.woff2
).