Support vertical metrics in Metrics#1552
Open
valadaptive wants to merge 1 commit intogooglefonts:mainfrom
Open
Support vertical metrics in Metrics#1552valadaptive wants to merge 1 commit intogooglefonts:mainfrom
Metrics#1552valadaptive wants to merge 1 commit intogooglefonts:mainfrom
Conversation
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
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
AdjustedMetricsreturned when outlining a glyph does not yet include vertical metrics--theMetricsmetadata 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,AdjustedMetricsis 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 theFT_LOAD_VERTICAL_LAYOUTflag--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 anHVMetricshelper 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
VORGtable 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.