MFEK / glifparser.rlib

A parser and writer for UFO `.glif` files.
Other
8 stars 6 forks source link

`glifparser` can't handle quadratic contours containing only interpolated points #36

Open ctrlcctrlv opened 2 years ago

ctrlcctrlv commented 2 years ago

Consider this quadratic period, points displayed with FontForge semantics:

image

<?xml version="1.0"?>
<glyph name="period" format="2">
  <advance width="1000"/>
  <unicode hex="002E"/>
  <outline>
    <contour>
      <point x="134" y="35"/>
      <point x="134" y="530"/>
      <point x="612" y="530"/>
      <point x="612" y="35"/>
    </contour>
  </outline>
</glyph>

All its points are interpolated. This is valid.

But glifparser uses the existence of a qcurve to know a contour is quadratic, so we no contour in MFEKglif!

If I tell FontForge to never interpolate one point, as:

…
  <outline>
    <contour>
      <point x="373" y="35" type="qcurve" smooth="yes"/>
      <point x="134" y="35"/>
      <point x="134" y="530"/>
      <point x="612" y="530"/>
      <point x="612" y="35"/>
    </contour>
  </outline>
…

We do draw it right:

image

But if I move the first QCurve we get buggy display:

image

Because QClose doesn't get a point drawn for it. Ruh-roh.

@MatthewBlanchard's pen work is definitely needed. :)