instancer: include attribute axisValues
This commit is contained in:
parent
f89c01d2d7
commit
b4b1ce3579
@ -1312,22 +1312,24 @@ def axisValueIsSelected(axisValue, seeker):
|
||||
return True if all(res) else False
|
||||
|
||||
axisIndex = axisValue.AxisIndex
|
||||
if axisIndex not in seeker:
|
||||
return False
|
||||
|
||||
if axisValue.Format in (1, 3):
|
||||
# Add axisValue if it's used to link to another variable font
|
||||
if axisIndex not in seeker and axisValue.Value == 1.0:
|
||||
# Add axisValue if it's an attribute of a font. Font family
|
||||
if axisIndex not in seeker and axisValue.Value in [0.0, 1.0]:
|
||||
return True
|
||||
|
||||
elif axisValue.Value == seeker[axisIndex]:
|
||||
elif axisIndex in seeker and axisValue.Value == seeker[axisIndex]:
|
||||
return True
|
||||
|
||||
if axisValue.Format == 2:
|
||||
return True if all([
|
||||
seeker[axisIndex] >= axisValue.RangeMinValue,
|
||||
seeker[axisIndex] <= axisValue.RangeMaxValue
|
||||
axisIndex in seeker and seeker[axisIndex] >= axisValue.RangeMinValue,
|
||||
axisIndex in seeker and seeker[axisIndex] <= axisValue.RangeMaxValue
|
||||
]) else False
|
||||
|
||||
if axisIndex not in seeker:
|
||||
return False
|
||||
|
||||
return False
|
||||
|
||||
|
||||
@ -1358,7 +1360,6 @@ def axisValuesFromAxisLimits(stat, axisLimits):
|
||||
axisValues = [a for a in axisValues if axisValueIsSelected(a, axisValuesToFind)]
|
||||
axisValuesMissing = set(axisValuesToFind) - set(axisValuesIndexes(axisValues))
|
||||
if axisValuesMissing:
|
||||
# TODO better error msg
|
||||
missing = [f"{axisTag[i]}={axisValuesToFind[i]}" for i in axisValuesMissing]
|
||||
raise ValueError(f"Cannot find AxisValue for {', '.join(missing)}")
|
||||
# filter out Elidable axisValues
|
||||
|
@ -2009,6 +2009,29 @@ def test_updateNameTable_missing_axisValues(varfont):
|
||||
instancer.updateNameTable(varfont, {"wght": 200})
|
||||
|
||||
|
||||
def test_updateNameTable_vf_with_italic_attribute(varfont):
|
||||
font_link_axisValue = varfont["STAT"].table.AxisValueArray.AxisValue[4]
|
||||
font_link_axisValue.Flags = 0
|
||||
font_link_axisValue.ValueNameID = 294 # Roman --> Italic
|
||||
|
||||
# Italic
|
||||
instancer.updateNameTable(varfont, {"wght": 400})
|
||||
names = _get_name_records(varfont)
|
||||
assert names[(1, 3, 1, 0x409)] == "Test Variable Font"
|
||||
assert names[(2, 3, 1, 0x409)] == "Italic"
|
||||
assert (16, 3, 1, 0x405) not in names
|
||||
assert (17, 3, 1, 0x405) not in names
|
||||
|
||||
# Black Condensed Italic
|
||||
instancer.updateNameTable(varfont, {"wdth": 79, "wght": 900})
|
||||
names = _get_name_records(varfont)
|
||||
assert names[(1, 3, 1, 0x409)] == "Test Variable Font Black Condensed"
|
||||
assert names[(2, 3, 1, 0x409)] == "Italic"
|
||||
assert names[(6, 3, 1, 0x409)] == "TestVariableFont-BlackCondensedItalic"
|
||||
assert names[(16, 3, 1, 0x409)] == "Test Variable Font"
|
||||
assert names[(17, 3, 1, 0x409)] == "Black Condensed Italic"
|
||||
|
||||
|
||||
def test_sanityCheckVariableTables(varfont):
|
||||
font = ttLib.TTFont()
|
||||
with pytest.raises(ValueError, match="Missing required table fvar"):
|
||||
|
Loading…
x
Reference in New Issue
Block a user