You need to enable JavaScript to run this app.
最新活动
大模型
产品
解决方案
定价
生态与合作
支持与服务
开发者
了解我们

如何从OpenType可变字体生成字体实例?用AFDKO处理OpenType 1.8可变字体

Generating Static Font Instances from OpenType 1.8 Variable Fonts

Great question! Let's walk through exactly how to generate static, widely-supported font instances from your OpenType 1.8 variable font—starting with AFDKO (since you specifically asked about it), then covering general methods that work across tools.

Using AFDKO (Adobe Font Development Kit for OpenType)

AFDKO is a tried-and-true tool for this task, and it’s straightforward once you know the commands. Here’s how to use it:

1. Install AFDKO

First, get AFDKO set up. The easiest way is via pip (it’s available on PyPI now):

pip install afdko

If you prefer a standalone build, you can grab it from Adobe’s official repo, but the pip method is simpler for most users.

2. Identify Your Font’s Variable Axes

Before generating instances, you need to know which axes your font supports (like weight, italic) and their valid ranges. Use the tx tool (part of AFDKO) to list them:

tx -l your-variable-font.ttf

You’ll get output that looks something like this:

Axes: wght (Weight) min 100, max 900; ital (Italic) min 0, max 1

Jot down the axis tags (e.g., wght, ital) and their min/max values so you can pick valid instance values.

3. Generate Single or Multiple Static Instances

Use tx again to extract specific static instances. The basic syntax is:

tx -c "axis1=value,axis2=value" input-variable-font.ttf output-static-font.ttf

For example, to make a bold (700 weight) non-italic instance:

tx -c "wght=700" my-var-font.ttf my-font-bold.ttf

Want an italic light instance? Try:

tx -c "wght=300,ital=1" my-var-font.ttf my-font-light-italic.ttf

If you need multiple instances at once, create a simple text file (e.g., instance-config.txt) with one instance per line:

wght=100
wght=400
wght=700,ital=1

Then run:

tx -i instance-config.txt my-var-font.ttf

This will generate separate static fonts for each entry, auto-named with the axis values (like my-var-font_wght100.ttf).

4. Validate Your Output

Always double-check that the generated static fonts are valid OpenType files. Use AFDKO’s otfvalidator for this:

otfvalidator my-font-bold.ttf

If there are no errors, you’re good to go.

General Methods for Generating Static Instances

If AFDKO isn’t your style, here are other reliable approaches that work for variable fonts:

1. FontTools (Python Library)

FontTools is a powerful open-source tool loved by font developers. Install it first:

pip install fonttools

Then use the varLib.instancer module to generate instances. For a single bold instance:

fonttools varLib.instancer my-var-font.ttf --output my-font-bold.ttf wght=700

To batch-generate multiple instances and save them to a folder:

fonttools varLib.instancer my-var-font.ttf --output-dir ./static-fonts wght=100 wght=400 wght=700,ital=1

2. GUI Tools (No Command Line Needed)

If you prefer a visual interface, these tools make instance generation a breeze:

  • FontLab 7/8: Open your variable font, go to File > Generate Instances, select the axes and values you want, then export as static TTF/OTF. It handles metadata (like font names) automatically.
  • Glyphs 3: Import your variable font, use the Instances panel to define your desired styles, then export via File > Export > Instances.
  • FontForge: While its variable font support is a bit limited, you can open the font, adjust the axis sliders to your desired values, then save as a static font.

3. Other Command-Line Tools

  • Variable Font Toolbox: A collection of scripts built on FontTools that simplifies variable font tasks, including instance generation.
  • ttfautohint: Useful if you want to add hinting to your static instances during generation, though it’s more for post-processing.

Pro Tip: Always verify the metadata (font family name, style name) of your generated static fonts. Most tools handle this automatically, but using a font inspector (like FontBook on macOS or Character Map on Windows) ensures your fonts show up correctly in apps and OS menus.

内容的提问来源于stack exchange,提问作者TitanSnow

火山引擎 最新活动