fontsbezierfontforgeufo

How are glyph points given in a UFO font?


I try to capture the glyph points/paths (not using the font). I converted the glyph to UFO.

<contour>
  <point x="281" y="646" type="qcurve"/>
  <point x="273" y="599"/>
  <point x="225" y="411"/>
  <point x="216" y="363" type="qcurve"/>
  <point x="320" y="382"/>
  <point x="426" y="445" type="qcurve"/>
  <point x="603" y="552"/>
  <point x="603" y="626" type="qcurve"/>
  <point x="603" y="676"/>
  <point x="502" y="676" type="qcurve"/>
  <point x="420" y="676"/>
</contour>

According to the manual, qcurve stands for quadratic curves derived from TrueType. Thus, we can calculate two bezier control points from one quadratic control point by

CP1 = QP0 + 2/3 *(QP1-QP0)
CP2 = QP2 + 2/3 *(QP1-QP2)

In this case, we should have one control point between two points (see the first four lines; there are two control points).

How can we transform a quadratic curve with two control points to bezier curve?


Solution

  • There is no such thing as a quadratic curve with two control points. By definition, it only has one. However, TryeType has a condensed point representation that removes on-curve points that lie exactly between the control points of consecutive quadratic curves, so the point list you see in the UFO file simply maps to TrueType's own "on curve" and "off curve" definition for points.

    As the UFO documentation explains, this requires special handling, so see the "Why do more than one consecutive off-curve points appear in glyph outline?" Stackoverflow post and answer for how to interpret sequences like this.