In CPAL/COLR font accented letters created automatically with diacritical marks and base letters. Is there a method to make them the same color as their base letters without adding color layers?
I’ve tried “Convert Layerfont to CPAL+COLR font” script but I guess it is not used for this scenario.
Yes, just put the components on the respective iColor letter. Not sure I understand your question though. Can you post a mock-up of what you want to achieve?
My question was is there a way to export the accented glyphs as coloured as their base glyphs without adding the same color layers to the all of them one by one? I hope this explains well.
You need to add the color layers ot the accented letters, too. Duplicate the default layers for each color and the components will match to the color layers.
Color Palette layers should be added anyway.
Here a script to automate it (if anyone will be looking for it in a future).
font = Glyphs.font
id = font.selectedFontMaster.id
for glyph in font.glyphs:
layer = glyph.layers[id]
if layer.components:
for component in layer.components:
source = component.component.layers[layer.associatedMasterId].parent
for sourceLayer in source.layers:
if sourceLayer.attributes['colorPalette'] or sourceLayer.attributes['colorPalette'] == 0:
newLayer = GSLayer()
newLayer.associatedMasterId = id
newLayer.attributes['colorPalette'] = sourceLayer.attributes['colorPalette']
colorComponent = GSComponent(source)
colorComponent.automaticAlignment = False
colorComponent.x = component.x
colorComponent.y = component.y
newLayer.components.append(colorComponent)
layer.parent.layers.append(newLayer)
newLayer.syncMetrics()
Hi Michael
This code is great thanks - could you show me how to change it so it just alters any glyphs that are selected rather than the whole Master please?
I’m trying something with “font.selectedLayers” following the tutorials but keep getting errors.
Thanks
Hi Andrew!
You were very close regarding font.selectedLayers
Here the code for just a selected glyphs:
font = Glyphs.font
id = font.selectedFontMaster.id
for selectedLayer in font.selectedLayers:
glyph = selectedLayer.parent
layer = glyph.layers[id]
if layer.components:
for component in layer.components:
source = component.component.layers[layer.associatedMasterId].parent
for sourceLayer in source.layers:
if sourceLayer.attributes['colorPalette'] or sourceLayer.attributes['colorPalette'] == 0:
newLayer = GSLayer()
newLayer.associatedMasterId = id
newLayer.attributes['colorPalette'] = sourceLayer.attributes['colorPalette']
colorComponent = GSComponent(source)
colorComponent.automaticAlignment = False
colorComponent.x = component.x
colorComponent.y = component.y
newLayer.components.append(colorComponent)
layer.parent.layers.append(newLayer)
newLayer.syncMetrics()