@@ -128,7 +128,7 @@ def buildVariableGlyphFromLayerGlyphs(layerGlyphs):
128
128
if defaultComponents :
129
129
layers ["foreground" ].glyph .components += defaultComponents
130
130
131
- fontraLayerNameMapping = defaultGlyph .lib .get ("fontra.layerNames" , {})
131
+ fontraLayerNameMapping = dict ( defaultGlyph .lib .get ("fontra.layerNames" , {}) )
132
132
133
133
dcNames = [c .name for c in defaultComponents ]
134
134
@@ -171,6 +171,10 @@ def buildVariableGlyphFromLayerGlyphs(layerGlyphs):
171
171
# We'll delete it to make sure we don't reuse its data
172
172
layers .pop (layerName , None )
173
173
174
+ fontraLayerNameMapping [layerName ] = varDict .get (
175
+ "fontraLayerName"
176
+ ) or fontraLayerNameMapping .get (layerName , layerName )
177
+
174
178
syntheticLayerNames .add (layerName )
175
179
176
180
xAdvance = defaultGlyph .width
@@ -314,11 +318,14 @@ def buildLayerGlyphsFromVariableGlyph(
314
318
315
319
if layerGlyph .hasOutlineOrClassicComponents ():
316
320
safeLayerName = makeSafeLayerName (source .layerName )
321
+ varDict ["layerName" ] = safeLayerName
317
322
if safeLayerName != source .layerName :
318
323
fontraLayerNameMapping [safeLayerName ] = source .layerName
319
- varDict ["layerName " ] = safeLayerName
324
+ varDict ["fontraLayerName " ] = source . layerName
320
325
else :
321
326
varDict ["layerName" ] = "" # Mimic RoboCJK
327
+ if source .layerName != source .name :
328
+ varDict ["fontraLayerName" ] = source .layerName
322
329
# This is a "virtual" layer: all info will go to defaultGlyph.lib,
323
330
# and no "true" layer will be written
324
331
del layerGlyphs [source .layerName ]
@@ -331,14 +338,14 @@ def buildLayerGlyphsFromVariableGlyph(
331
338
defaultGlyph .lib .pop ("robocjk.variationGlyphs" , None )
332
339
333
340
if fontraLayerNameMapping :
334
- defaultGlyph .lib ["fontra.layerNames" ] = fontraLayerNameMapping
335
341
rcjkLayerNameMapping = {v : k for k , v in fontraLayerNameMapping .items ()}
336
342
layerGlyphs = {
337
343
rcjkLayerNameMapping .get (layerName , layerName ): layerGlyph
338
344
for layerName , layerGlyph in layerGlyphs .items ()
339
345
}
340
- else :
341
- defaultGlyph .lib .pop ("fontra.layerNames" , None )
346
+
347
+ # Get rid of legacy data
348
+ defaultGlyph .lib .pop ("fontra.layerNames" , None )
342
349
343
350
return layerGlyphs
344
351
0 commit comments