Merge pull request #3132 from fonttools/fealib-simplify-variablescaler
[feaLib] Simplify variable scalars that don’t vary
This commit is contained in:
commit
96bede39e7
@ -1606,6 +1606,26 @@ class Builder(object):
|
|||||||
|
|
||||||
self.conditionsets_[key] = value
|
self.conditionsets_[key] = value
|
||||||
|
|
||||||
|
def makeVariablePos(self, location, varscalar):
|
||||||
|
if not self.varstorebuilder:
|
||||||
|
raise FeatureLibError(
|
||||||
|
"Can't define a variable scalar in a non-variable font", location
|
||||||
|
)
|
||||||
|
|
||||||
|
varscalar.axes = self.axes
|
||||||
|
if not varscalar.does_vary:
|
||||||
|
return varscalar.default, None
|
||||||
|
|
||||||
|
default, index = varscalar.add_to_variation_store(
|
||||||
|
self.varstorebuilder, self.model_cache, self.font.get("avar")
|
||||||
|
)
|
||||||
|
|
||||||
|
device = None
|
||||||
|
if index is not None and index != 0xFFFFFFFF:
|
||||||
|
device = buildVarDevTable(index)
|
||||||
|
|
||||||
|
return default, device
|
||||||
|
|
||||||
def makeOpenTypeAnchor(self, location, anchor):
|
def makeOpenTypeAnchor(self, location, anchor):
|
||||||
"""ast.Anchor --> otTables.Anchor"""
|
"""ast.Anchor --> otTables.Anchor"""
|
||||||
if anchor is None:
|
if anchor is None:
|
||||||
@ -1616,7 +1636,6 @@ class Builder(object):
|
|||||||
deviceX = otl.buildDevice(dict(anchor.xDeviceTable))
|
deviceX = otl.buildDevice(dict(anchor.xDeviceTable))
|
||||||
if anchor.yDeviceTable is not None:
|
if anchor.yDeviceTable is not None:
|
||||||
deviceY = otl.buildDevice(dict(anchor.yDeviceTable))
|
deviceY = otl.buildDevice(dict(anchor.yDeviceTable))
|
||||||
avar = self.font.get("avar")
|
|
||||||
for dim in ("x", "y"):
|
for dim in ("x", "y"):
|
||||||
varscalar = getattr(anchor, dim)
|
varscalar = getattr(anchor, dim)
|
||||||
if not isinstance(varscalar, VariableScalar):
|
if not isinstance(varscalar, VariableScalar):
|
||||||
@ -1625,20 +1644,13 @@ class Builder(object):
|
|||||||
raise FeatureLibError(
|
raise FeatureLibError(
|
||||||
"Can't define a device coordinate and variable scalar", location
|
"Can't define a device coordinate and variable scalar", location
|
||||||
)
|
)
|
||||||
if not self.varstorebuilder:
|
default, device = self.makeVariablePos(location, varscalar)
|
||||||
raise FeatureLibError(
|
|
||||||
"Can't define a variable scalar in a non-variable font", location
|
|
||||||
)
|
|
||||||
varscalar.axes = self.axes
|
|
||||||
default, index = varscalar.add_to_variation_store(
|
|
||||||
self.varstorebuilder, self.model_cache, avar
|
|
||||||
)
|
|
||||||
setattr(anchor, dim, default)
|
setattr(anchor, dim, default)
|
||||||
if index is not None and index != 0xFFFFFFFF:
|
if device is not None:
|
||||||
if dim == "x":
|
if dim == "x":
|
||||||
deviceX = buildVarDevTable(index)
|
deviceX = device
|
||||||
else:
|
else:
|
||||||
deviceY = buildVarDevTable(index)
|
deviceY = device
|
||||||
variable = True
|
variable = True
|
||||||
|
|
||||||
otlanchor = otl.buildAnchor(
|
otlanchor = otl.buildAnchor(
|
||||||
@ -1659,7 +1671,6 @@ class Builder(object):
|
|||||||
if not v:
|
if not v:
|
||||||
return None
|
return None
|
||||||
|
|
||||||
avar = self.font.get("avar")
|
|
||||||
vr = {}
|
vr = {}
|
||||||
for astName, (otName, isDevice) in self._VALUEREC_ATTRS.items():
|
for astName, (otName, isDevice) in self._VALUEREC_ATTRS.items():
|
||||||
val = getattr(v, astName, None)
|
val = getattr(v, astName, None)
|
||||||
@ -1674,18 +1685,9 @@ class Builder(object):
|
|||||||
raise FeatureLibError(
|
raise FeatureLibError(
|
||||||
"Can't define a device coordinate and variable scalar", location
|
"Can't define a device coordinate and variable scalar", location
|
||||||
)
|
)
|
||||||
if not self.varstorebuilder:
|
vr[otName], device = self.makeVariablePos(location, val)
|
||||||
raise FeatureLibError(
|
if device is not None:
|
||||||
"Can't define a variable scalar in a non-variable font",
|
vr[otDeviceName] = device
|
||||||
location,
|
|
||||||
)
|
|
||||||
val.axes = self.axes
|
|
||||||
default, index = val.add_to_variation_store(
|
|
||||||
self.varstorebuilder, self.model_cache, avar
|
|
||||||
)
|
|
||||||
vr[otName] = default
|
|
||||||
if index is not None and index != 0xFFFFFFFF:
|
|
||||||
vr[otDeviceName] = buildVarDevTable(index)
|
|
||||||
else:
|
else:
|
||||||
vr[otName] = val
|
vr[otName] = val
|
||||||
|
|
||||||
|
@ -2,4 +2,5 @@ languagesystem DFLT dflt;
|
|||||||
feature kern {
|
feature kern {
|
||||||
pos one 1;
|
pos one 1;
|
||||||
pos two <0 (wght=200:12 wght=900:22 wdth=150,wght=900:42) 0 0>;
|
pos two <0 (wght=200:12 wght=900:22 wdth=150,wght=900:42) 0 0>;
|
||||||
|
pos three <0 (wght=200:12 wght=900:12 wdth=150,wght=900:12) 0 0>;
|
||||||
} kern;
|
} kern;
|
||||||
|
@ -76,7 +76,7 @@
|
|||||||
<Lookup index="0">
|
<Lookup index="0">
|
||||||
<LookupType value="1"/>
|
<LookupType value="1"/>
|
||||||
<LookupFlag value="0"/>
|
<LookupFlag value="0"/>
|
||||||
<!-- SubTableCount=2 -->
|
<!-- SubTableCount=3 -->
|
||||||
<SinglePos index="0" Format="1">
|
<SinglePos index="0" Format="1">
|
||||||
<Coverage>
|
<Coverage>
|
||||||
<Glyph value="one"/>
|
<Glyph value="one"/>
|
||||||
@ -97,6 +97,13 @@
|
|||||||
</YPlaDevice>
|
</YPlaDevice>
|
||||||
</Value>
|
</Value>
|
||||||
</SinglePos>
|
</SinglePos>
|
||||||
|
<SinglePos index="2" Format="1">
|
||||||
|
<Coverage>
|
||||||
|
<Glyph value="three"/>
|
||||||
|
</Coverage>
|
||||||
|
<ValueFormat value="2"/>
|
||||||
|
<Value YPlacement="12"/>
|
||||||
|
</SinglePos>
|
||||||
</Lookup>
|
</Lookup>
|
||||||
</LookupList>
|
</LookupList>
|
||||||
</GPOS>
|
</GPOS>
|
||||||
|
Loading…
x
Reference in New Issue
Block a user