Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Reading glyph.height from file #273

Open
schriftgestalt opened this issue May 19, 2023 · 5 comments
Open

Reading glyph.height from file #273

schriftgestalt opened this issue May 19, 2023 · 5 comments

Comments

@schriftgestalt
Copy link

When reading a .glif, the glyph.height is set to zero if it is not defined in the file. That makes it impossible to distinguish between manually defined zero height glyphs and just default/undefined ones. Would it be better to set glyph.height to None if not defined in the file?

I came across this when round tripping .glyphs > .ufo > .glyphs as the resulting .glyphs files have vertwidth = 0 for all glyphs. That is clearly wrong.

@anthrotype
Copy link
Member

It is not "wrong", it's just how the UFO spec defines it currently. I have actually proposed to change the default height value but it will be a breaking change so would probably requires a UFO spec major version bump.

unified-font-object/ufo-spec#95 (comment)

@madig
Copy link
Collaborator

madig commented May 19, 2023

How does height work, anyway? Does it always require a vertical origin?

@anthrotype
Copy link
Member

Does it always require a vertical origin?

if omitted for a specific glyph, we have it default to the OS/2.sTypoAscender currently:

https://github.com/googlefonts/ufo2ft/blob/0d2688cd847d003b41104534d16973f72ef26c40/Lib/ufo2ft/outlineCompiler.py#L68-L75

height defines the vertical advance in vmtx (like width does for hmtx). The vertical origin is used to compute the top side bearing defined as (verticalOrigin - bounds.yMax)

https://github.com/googlefonts/ufo2ft/blob/0d2688cd847d003b41104534d16973f72ef26c40/Lib/ufo2ft/outlineCompiler.py#L869C30-L872

@madig
Copy link
Collaborator

madig commented May 20, 2023

Ok. In my format experiments, I was tempted to treat a UFO glyph's origin and height as a unit, as in, the height is only defined if there's an explicit origin also present. Could this be a band-aid for the g2u2g case? I.e. the origin cannot be implicit, and that's how you can tell if a glyph has a zero height (origin and height diff to 0) or an undefined one (no origin).

@schriftgestalt How does height work in Glyphs.app?

@schriftgestalt
Copy link
Author

The height (called vertWidth) defaults to ascender+descender.
The vertOrigin defaults to ascender.
A vmtx table is written if any glyph has a different value set (implicitly or explicitly) for each property.

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

No branches or pull requests

3 participants