Skip to content

Commit

Permalink
Merge pull request #1098 from Hoolean/use-py-metrics
Browse files Browse the repository at this point in the history
Allow USE_MY_METRICS when dx is negligible, matching ufo2ft
  • Loading branch information
anthrotype authored Nov 7, 2024
2 parents f445452 + d47f4f6 commit 55a9628
Showing 1 changed file with 13 additions and 2 deletions.
15 changes: 13 additions & 2 deletions fontbe/src/glyphs.rs
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ pub fn create_glyf_work(glyph_name: GlyphName) -> Box<BeWork> {
///
/// * The same advance width as glyph
/// * A 2x2 transform that does nothing (basis vectors do not change)
/// * No x-translation
/// * No x-translation that will survive rounding
/// * y-translation is OK
///
/// This forces the composite glyph to use the possibly hinted horizontal
Expand All @@ -75,8 +75,9 @@ fn can_reuse_metrics(
if width != component_glyph.width.ot_round() {
return false;
}
// transform needs to be identity ignoring dy
// transform needs to be identity ignoring dy, and dx if it will be rounded away
let mut coeffs = transform.as_coeffs();
coeffs[4] = coeffs[4].ot_round();
coeffs[5] = 0.0;
coeffs == Affine::IDENTITY.as_coeffs()
}
Expand Down Expand Up @@ -939,6 +940,16 @@ mod tests {
));
}

#[test]
fn can_reuse_metrics_ignores_negligible_dx() {
let (glyph, component) = create_reusable_component();
assert!(can_reuse_metrics(
&glyph,
&component,
&Affine::translate((0.4, 0.0))
));
}

#[test]
fn cannot_reuse_metrics_for_non_dy_transform() {
let (glyph, component) = create_reusable_component();
Expand Down

0 comments on commit 55a9628

Please sign in to comment.