Skip to content

[instantiator] allow explicitly empty glyphs in non-default sources - #1018

Merged
anthrotype merged 1 commit into
mainfrom
empty-not-sparse
Nov 2, 2026
Merged

anthrotype merged 1 commit into
mainfrom
empty-not-sparse

Conversation

@anthrotype

Copy link
Copy Markdown
Member

When the default source's glyph has outlines, the instantiator treats an empty glyph in another source as missing from that source ("sparse") and interpolates it from the remaining ones. This follows two older conventions. ufoProcessor's collectMastersForGlyph drops such empty sources ("if the default glyph is not empty then none can be empty"), and fontmake's instantiator, which later moved here, copied that behaviour. varLib does the same when building gvar, since fonttools/fonttools#2082, which came out of #408: components are resolved within the same UFO layer, so a source that only varies the offsets of some composites still has to contain their base glyphs, and leaving those empty means they don't take part in the variation.

The convention can't tell such a placeholder from a glyph that is really meant to be empty in that source. In Glyphs.app only brace (intermediate) layers are sparse; a master layer that is left empty is meant to be empty, and Glyphs and fontc export it as such, whereas fontmake fills the static instance from the other masters.

I'm not thrilled about adding yet another private lib key, but I couldn't find a way around it. The two cases look identical in a UFO, and the distinction is per glyph, not per source: any non-default source, a full master included, may be sparse for some glyphs, so a flag on the source descriptor wouldn't do. Only the tool that produced the UFOs knows which empty glyphs are intentional, so it has to say so. The name I came up with is com.github.googlei18n.ufo2ft.instantiator.emptyNotSparse. An empty glyph that sets it is kept as a master: an instance at that source stays empty, and an instance between it and incompatible sources raises the usual interpolation error. Unmarked glyphs behave as before, and variable fonts are not affected. A companion glyphsLib PR will set the key on glyphs that are empty in a non-default master (never in brace layers).

The instantiator treats a glyph that is empty in a non-default source,
while the default has outlines, as sparse and drops that source, so an
instance there gets the outlines interpolated from the other sources.
That convention lets sparse sources keep empty placeholder base glyphs
for the components they vary.

A glyph lib key, com.github.googlei18n.ufo2ft.instantiator.emptyNotSparse,
now marks an empty glyph as meant to be empty (e.g. a master layer drawn
empty in Glyphs). Such a glyph is kept as a master: an instance at that
source stays empty, and an instance between it and incompatible sources
raises the usual interpolation error. Unmarked glyphs behave as before.
@behdad

behdad commented Nov 2, 2026

Copy link
Copy Markdown
Collaborator

LGTM.

@anthrotype
anthrotype merged commit 541fd0e into main Nov 2, 2026
15 checks passed
anthrotype added a commit to arrowtype/glyphsLib that referenced this pull request Nov 4, 2026
In Glyphs an empty master layer is meant to be empty, but ufo2ft's
instantiator treats a glyph that is empty in a non-default source,
while the default has outlines, as sparse and interpolates it from the
other sources. So static instances built from the designspace get
glyphs that Glyphs.app and fontc leave empty.

Set the com.github.googlei18n.ufo2ft.instantiator.emptyNotSparse glyph
lib key (googlefonts/ufo2ft#1018) on glyphs that are empty in a
non-default master when the default master's layer has paths or
components, bracket alternates included. Brace layers are sparse in
Glyphs as well and are never marked. The key is recomputed on each
conversion, so it is dropped when going back to Glyphs.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants