Skip to content

Instantly share code, notes, and snippets.

@be5invis
Last active December 16, 2019 02:08
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save be5invis/8967147c3cf6f9e28a5a8e9852b2edf9 to your computer and use it in GitHub Desktop.
Save be5invis/8967147c3cf6f9e28a5a8e9852b2edf9 to your computer and use it in GitHub Desktop.

OpenType “Neo Geometry Architecture”

Static coordinate data

  • nKnots : UInt16 – Number of control knots in this contour set.
  • flags : StaticCoordFlag ^ nKnots – Flag array.
  • xData, yData : Bytes – Compressed X and Y coordinate data, driven by flags.

StaticCoordFlag

Flags are bytes described as follows: SC FR ZC-ZC XT-XT YT-YT

  • SC: Start of contour. First flag implicitly sets this bit.
  • FR: Fraction coordinates.
  • ZC: Decides the type of this knot.
    • TBD: may be cubic only or a 2-3 MD spline with 0-1 knot intervals.
    • MD looks too complex but it is the way to main compatibility with both cubic and quadratic outlines with exact 1-1 knot mapping.
  • XT, YT: X/Y coordinate type.
    • 00: Zero
    • 01: Positive short (Unsigned 8-bit or unsigned 8.8)
    • 10: Negative short (Unsigned 8-bit or unsigned 8.8)
    • 11: Long (signed 16-bit or signed 16.16)

Polymorphic coordinate data

  • nVariance : UInt16 – Number of variance masters applied.
  • variations : ContourSetVariance ^ nVariance – Array of variance application.

ContourSetVariance

  • masterId : UInt16 – Index of master.
  • flags : Array PolyCoordFlag – Enough to cover all knots. See below.
  • deltaX, deltaY : Bytes – Compressed delta data, driven by flags.

PolyCoordFlag

Each flag may occupy 1–3 bytes: one leading byte decides the format of variance coordinates; the rest bytes decides how many points are affected.

Leading byte format: 00 FR NT-NT XT-XT YT-YT

  • FR: X and Y delta coordinates are fraction.
  • NT: Type of trailing point number indicator.
    • 00: Applies to one point. No trailing bytes.
    • 01: Byte. Next byte represents the quantity of points affected minus one.
    • 10: Short. Next two bytes, grouped together into a 16-bit unsigned integer represents the quantity of points affected minus one.
    • 11: Applies to all remaining points. No trailing bytes.
  • XT, YT: Type of X and Y delta coordinates.
    • 00: Zero. No data byte.
    • 01: Signed byte or 8.8.
    • 10: Signed short or 16.16.
    • 11: Implicit. The coordinate is implicitly interpolated using IUP. No data byte.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment