Workaround: Convert Variable Fonts to Static Fonts #2508
YDX-2147483647
started this conversation in
Show and tell
Replies: 1 comment
-
Workaround for Fonts Lacking Bold Variants: Use FontForge to Generate One#394 (comment) mentioned a python script to generate a fake bold version TTF. import fontforge
NAME = "simfang"
f = fontforge.open(f"{NAME}.ttf")
f.selection.all()
f.os2_weight = 700
f.changeWeight(10).generate(f"{NAME}-Bold.ttf")(I have NOT tested it either) |
Beta Was this translation helpful? Give feedback.
0 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
-
Background
Typst does not support variable fonts yet.
Workaround: Use fontTools to Convert Variable Fonts to Static Fonts
python -m pip install fonttools richvar_file.Note
If you only need a single weight (e.g. regular / 400), you can use fonttools's CLI:
Example
Bitter - Google Fonts provides both static and variable fonts.
Download family and organize files as the following.
./ ├── static/ │ ├── Bitter-Black.ttf │ ├── Bitter-Bold.ttf │ ├── … │ └── Bitter-Thin.ttf └── variable/ └── Bitter-VariableFont_wght.ttftypst fonts --variantsimplies that only the base axes is supported:Save the following test document to
main.typ.Compile it.
Run the python script mentioned above to convert the variable font to
*-mutator-*.ttf../ ├── static/ │ └── … └── variable/ ├── Bitter-VariableFont_wght-mutator-100.0.ttf ├── Bitter-VariableFont_wght-mutator-200.0.ttf ├── … ├── Bitter-VariableFont_wght-mutator-900.0.ttf └── Bitter-VariableFont_wght.ttfNow verify
*-mutator-*.ttf.Alternatives
(I have NOT tested them)
jonpalmisc/vfit: Utility for building static cuts of variable fonts
Beta Was this translation helpful? Give feedback.
All reactions