Skip to content

Support vertical metrics in Metrics#1552

Open
valadaptive wants to merge 1 commit intogooglefonts:mainfrom
valadaptive:vertical-metrics-1
Open

Support vertical metrics in Metrics#1552
valadaptive wants to merge 1 commit intogooglefonts:mainfrom
valadaptive:vertical-metrics-1

Conversation

@valadaptive
Copy link
Copy Markdown
Contributor

I mainly implemented this because ttf-parser and swash support this, and its API consumers often expose that functionality. Superseding those packages will require implementing it here.

The AdjustedMetrics returned when outlining a glyph does not yet include vertical metrics--the Metrics metadata provider is already large and has some very involved preparsing code, so I don't feel bad about adding more to it. On the other hand, AdjustedMetrics is a lot smaller and is likely to be present in the hot path of laying out multiple glyphs, and we want to avoid computing metrics that may never be used and will likely be 0 for most non-CJK fonts. I'm not yet sure of the best way to expose that functionality. FreeType lets you specify whether you want the horizontal or vertical metrics using the FT_LOAD_VERTICAL_LAYOUT flag--would something similar here work well?

Some of the doc comments for the new metrics properties were swiped from Swash; the existing comments seem to be as well so that shouldn't be a big problem. I've put the vertical metrics in their own struct which may not be present; they are present/absent as a group, so I think that makes sense semantically.

For GlyphMetrics, I've added an HVMetrics helper struct for storing one "set" of metrics tables and metadata for each dimension (horizontal and vertical). I'm not sure if it's worth it to reduce boilerplate, but the code felt kinda ugly without it. I'm very open to removing it and just duplicating the parsing/conversion code.

I'm not parsing the VORG table for now; if I understand correctly, a glyph's vertical origin is the sort of thing you'd return when outlining a glyph, which I'm punting on for now.

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.

1 participant