[read-fonts] Add exact variation deltas to HVAR, VVAR and MVAR - #2110
Conversation
| /// implementations differ on that. | ||
| /// | ||
| /// Returns `None` where the table says nothing readable about the glyph. | ||
| pub fn v_org(&self, glyph_id: GlyphId, coords: &[F2Dot14]) -> Option<F48Dot16> { |
There was a problem hiding this comment.
I do generally wonder if these names aren't a bit too concise, but I understand how tsb and bsb would follow from lsb/rsb, which are names already in use, and if we're using those than I can see how you end up here? I'd probably still prefer vert_origin/v_origin though, personally..
There was a problem hiding this comment.
Agreed that this became worse when the _delta was dropped. Also, I realized that these aren't in our compatibility set so I'm just going to reuse the old names but extend v_org_delta to v_origin_y_delta which is what this actually is.
Should note that when I get to the later glyph metrics work on the new font API, lsb will be spelled h_bearing_x. Perhaps we can make similar changes to these later.
b06b13a to
81bfe72
Compare
These accessors rounded each delta to a whole design unit before returning
it. That is what most callers want and what the classic implementations do,
but a caller that rounds differently, or that accumulates several deltas
before rounding, could not recover what was discarded.
They now report what the item variation store computed:
Hvar::advance_delta, lsb_delta, rsb_delta
Vvar::advance_delta, tsb_delta, bsb_delta, v_origin_y_delta
all returning Option<F48Dot16>. The error they used to report told a caller
nothing it could act on, and none of them looked.
The names lose what the table already says. HVAR has only widths and VVAR
only heights, so advance_width_delta and advance_height_delta are both just
advance_delta. And v_org_delta spells out what it answers for: the y
coordinate of the vertical origin, the x being half the advance width and
stated by no table at all.
Mvar::at is added alongside, returning an MvarInstance that resolves the
variation store once and answers by tag, rather than resolving it on every
Mvar::metric_delta call.
Callers that rounded the old whole-unit value now round the exact one, so
what they compute is unchanged.
81bfe72 to
0b1b5a7
Compare
Expose 48.16 delta methods for the metrics variation tables.
MVARgets a helper that resolves the IVS once for batch queries.