Skip to content

Commit

Permalink
fix sources with layernames bug
Browse files Browse the repository at this point in the history
  • Loading branch information
typemytype committed May 17, 2024
1 parent 845e2ec commit 2257444
Showing 1 changed file with 7 additions and 4 deletions.
11 changes: 7 additions & 4 deletions source/lib/batchGenerators/variableFontsGenerator/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,14 +15,16 @@

from ufo2fdk.kernFeatureWriter import side1Prefix, side2Prefix

from batchGenerators.batchTools import postProcessCollector, WOFF2Builder, buildTree, removeTree, BatchEditorOperator
from batchGenerators.batchTools import postProcessCollector, WOFF2Builder, buildTree, removeTree, BatchEditorOperator, Report


class GenerateVariableFont:

def __init__(self, operator, destinationPath, autohint=False, fitToExtremes=False, releaseMode=True, glyphOrder=None, report=None, debug=False):
# this must be an operator with no discrete axes.
# split the designspace first first
if report is None:
report = Report()
self.operator = operator
self.destinationPath = destinationPath
self.binaryFormat = os.path.splitext(self.destinationPath)[-1][1:].lower()
Expand Down Expand Up @@ -293,19 +295,20 @@ def makeLayerMaster(self):
if sourceDescriptor.layerName is not None:
layerName = sourceDescriptor.layerName

path, ext = os.path.splitext(sourceDescriptor.path)
layeredUFOPath = sourceDescriptor.path

path, ext = os.path.splitext(layeredUFOPath)

sourceDescriptor.path = os.path.join(os.path.dirname(self.destinationPath), f"{path}-{layerName}{ext}")
sourceDescriptor.styleName = f"{sourceDescriptor.styleName} {layerName}"
sourceDescriptor.filename = None
sourceDescriptor.layerName = None

layeredSource = self.operator._instantiateFont(sourceDescriptor.path)
layeredSource = self.operator._instantiateFont(layeredUFOPath)
layeredSource.layers.defaultLayer = layeredSource.layers[layerName]
layeredSource.save(sourceDescriptor.path)

self.operator.fonts[sourceDescriptor.name] = layeredSource

self.generatedFiles.add(sourceDescriptor.path)

def generate(self):
Expand Down

0 comments on commit 2257444

Please sign in to comment.