Skip to content

[glyphs] Apply *origin to layer geometry, not just propagated anchors - #2072

Open
anthrotype wants to merge 3 commits into
mainfrom
fontc-glyphs-origin-shift
Open

[glyphs] Apply *origin to layer geometry, not just propagated anchors#2072
anthrotype wants to merge 3 commits into
mainfrom
fontc-glyphs-origin-shift

Conversation

@anthrotype

Copy link
Copy Markdown
Member

Glyphs.app treats *origin as a layer-wide coordinate shift: everything else on the layer is drawn as if *origin were at (0, 0) and then translated back by -origin. fontc only applied this to anchors, during propagation, and never to contours or components. Even that anchor adjustment was silently skipped for non-composite glyphs, because propagate_anchors only writes propagated anchors back for composite glyphs, so a simple glyph with *origin came out unshifted everywhere.

This applies the shift during Glyphs source conversion instead, to contours, components and the raw anchor collection, so simple glyphs are covered too.

propagate_anchors keeps the current origin_adjusted_anchors for other potential IR callers, but on the Glyphs path it becomes a no-op.

(related to #769 which handled the anchor half of this in 2024; this is the rest of it)

glyphsLib does the same thing as of googlefonts/glyphsLib#1155, which merged yesterday (July 31), so the two compilers will continue to agree.

We should hold this until a glyphsLib release containing googlefonts/glyphsLib#1155 is out and fontc requirements are bumped.

Shift contours, component transforms, and source anchors by -*origin during
Glyphs conversion. This also covers simple glyphs, whose anchors are not
rewritten by propagation; retain the generic IR adjustment for other callers.
const GLYPHS_ORIGIN_ANCHOR: &str = "*origin";

/// The `*origin` anchor's position, if the layer has one.
fn layer_origin(layer: &Layer) -> Option<kurbo::Point> {

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nit: layer.origin() or layer.find_origin() would be nicer, might it make sense to use a trait or move this into glyphs-reader?

unitsPerEm = 1000;
}"#,
)
.unwrap();

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

IMHO this would be nicer as an actual .glyphs file we load

Comment thread glyphs2fontir/src/source.rs Outdated
Try to denoise tests a little
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