googlefonts / googlefonts/glyphsLib

glyphs2ufo does not export unnamed brace layers

Open
#952 1 comment 0 reactions 0 assignees View on GitHub
Dominant language
Python
Stars
201
Forks
56
Avg merge
17m
Merged PRs (30d)
1

Description

## Problem

When glyphsLib is used to export a Glyphs file with unnamed brace layers (e.g. `""`), the brace layers receive a `` entry in the generated designspace but the referenced UFO layer is not created.

## Cause

We drop layers [if they have no name and are not bracket layers](https://github.com/googlefonts/glyphsLib/blob/cb8a4a91/Lib/glyphsLib/builder/builders.py#L295-L302), with no special treatment for brace layers. As [we generate our own layer names](https://github.com/googlefonts/glyphsLib/blob/cb8a4a91/Lib/glyphsLib/builder/layers.py#L39-L40) for brace layers, however, this is a false positive, and so we should keep them instead.

## Proposed Fix

We should only drop layers if all three of the following conditions are satisfied:
- The layer has no name
- The layer is not a bracket layer
- The layer is not a brace layer **(NEW)**

Alternatively, we could avoid dropping unnamed layers entirely, through some other means.

## Workaround

If you are affected by this issue, you can avoid it in your font sources by assigning distinct names to your brace layers:

e.g.

```python
from glyphsLib import GSFont

SOURCES = "MyFont.glyphs"

font = GSFont(SOURCES)

brace_layers = [
layer
for glyph in font.glyphs
for layer in glyph.layers
if layer._is_brace_layer()
]

for layer in brace_layers:
layer.name = layer._brace_layer_name()

font.save(SOURCES)
```

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.