googlefonts / fontc

Where in we pursue oxidizing (context: https://github.com/googlefonts/oxidize) fontmake.
Apache License 2.0
73 stars 12 forks source link

Google Sans has outlines we don't like #349

Closed rsheeter closed 1 year ago

rsheeter commented 1 year ago

https://github.com/googlefonts/googlesans/issues/586

anthrotype commented 1 year ago

The offending contour is in GoogleSans-opsz18-wght380-GRAD-50.ufo/glyphs/tzaa-ethiopic.glif, here's an excerpt:

    <contour>
      <point x="109" y="720"/>
      <point x="30" y="649"/>
      <point x="30" y="521" type="curve" smooth="yes"/>
[...]
      <point x="405" y="658"/>
      <point x="346" y="720"/>
      <point x="228" y="720" type="curve" smooth="yes"/>
    </contour>

looks like we don't add an inital MoveTo when the glif contour begin with off-curves like in this case, here's the generated IR generated from the above, which is missing the initial MoveTo and causing the panic:

    contours:
    - - !CurveTo
        - x: 109.0
          y: 720.0
        - x: 30.0
          y: 649.0
        - x: 30.0
          y: 521.0
[...]
      - !CurveTo
        - x: 405.0
          y: 658.0
        - x: 346.0
          y: 720.0
        - x: 228.0
          y: 720.0
anthrotype commented 1 year ago

when compiling in debug mode, kurbo contains debug_assert! statements that ensure that a valid BezPath always starts with a MoveTo. The OP run fontc as cargo run --release hence these were skipped, but then we panic later on in fontbe/glyphs.rs when converting curves to quadratics