Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
def empty_varfont(designspace_path):
designspace = fontTools.designspaceLib.DesignSpaceDocument.fromfile(
designspace_path
)
for source in designspace.sources:
source.font = testutil.empty_UFO(source.styleName)
ufo2ft.compileInterpolatableTTFsFromDS(designspace, inplace=True)
varfont, _, _ = fontTools.varLib.build(designspace)
return varfont
def generate_variable_font(
designspace_path: Path,
stylespace_path: Path,
additional_locations: Optional[Mapping[str, float]] = None,
) -> fontTools.ttLib.TTFont:
designspace = fontTools.designspaceLib.DesignSpaceDocument.fromfile(
designspace_path
)
for source in designspace.sources:
source.font = empty_UFO(source.styleName)
ufo2ft.compileInterpolatableTTFsFromDS(designspace, inplace=True)
varfont, _, _ = fontTools.varLib.build(designspace)
stylespace = statmake.classes.Stylespace.from_file(stylespace_path)
if additional_locations is None:
additional_locations = designspace.lib.get(
"org.statmake.additionalLocations", {}
)
statmake.lib.apply_stylespace_to_variable_font(
stylespace, varfont, additional_locations
)
return reload_font(varfont)
def _build_interpolatable_masters(
self,
designspace,
ttf,
use_production_names=None,
reverse_direction=True,
conversion_error=None,
feature_writers=None,
cff_round_tolerance=None,
debug_feature_file=None,
**kwargs,
):
designspace = self._load_designspace_sources(designspace)
if ttf:
return ufo2ft.compileInterpolatableTTFsFromDS(
designspace,
useProductionNames=use_production_names,
reverseDirection=reverse_direction,
cubicConversionError=conversion_error,
featureWriters=feature_writers,
debugFeatureFile=debug_feature_file,
inplace=True,
)
else:
return ufo2ft.compileInterpolatableOTFsFromDS(
designspace,
useProductionNames=use_production_names,
roundTolerance=cff_round_tolerance,
featureWriters=feature_writers,
debugFeatureFile=debug_feature_file,
inplace=True,