Skip to content

Where can I find variable font with format 4 axis value table? #2982

Answered by moi15moi
moi15moi asked this question in Q&A
Discussion options

You must be logged in to vote

Since I couldn't found an font with axis value that has format 4, I created one with fonttools:

from fontTools.ttLib.ttFont import TTFont
from fontTools.ttLib.tables import otTables

font = TTFont("original font.ttf")

axisValue = otTables.AxisValue()
axisValue.Format = 4
axisValue.Flags = XXX
axisValue.ValueNameID = XXX

axisValue.AxisValueRecord = []

# If you want to have an wght = 800 and ital = 0
for tag, value in (("wght", 800), ("ital", 0)):
    rec = otTables.AxisValueRecord()
    rec.AxisIndex = next(
        i for i, a in enumerate(font["STAT"].table.DesignAxisRecord.Axis) if a.AxisTag == tag
    )
    rec.Value = value
    axisValue.AxisValueRecord.append(rec)

font["STAT"].table.

Replies: 1 comment

Comment options

You must be logged in to vote
0 replies
Answer selected by moi15moi
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
1 participant