Skip to content

Instantly share code, notes, and snippets.

@simoncozens
Last active January 18, 2023 18: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 simoncozens/d4e4b67f26d7aaaf2d773b75ce436b5c to your computer and use it in GitHub Desktop.
Save simoncozens/d4e4b67f26d7aaaf2d773b75ce436b5c to your computer and use it in GitHub Desktop.

Justification with Variable Fonts

  • In JSTF header
Type Name Description
uint16 majorVersion Major version of the JSTF table, = 1
uint16 minorVersion Minor version of the JSTF table, = 0
uint16 jstfScriptCount Number of JstfScriptRecords in this table
JstfScriptRecord jstfScriptRecords[jstfScriptCount] Array of JstfScriptRecords, in alphabetical order by jstfScriptTag

replace = 0 with = 0 or 1.

  • Add the end of JstfPriority table insert:
Type Name Description
Offset16 jstfVariationOffset Offset to JstfVariation table (version 1.1 only; may be NULL)
  • Before JSTF Table Examples, insert:

Justification Variation Table

The Justification Variation Table instructs the text rendering system to apply OpenType Font Variations to certain glyphs. The table specifies a variation axis and a direction to be applied at the current priority level. The text rendering system is expected to adjust the position of the design space for the glyphs matching the current coverage (or all glyphs, if the coverage table is not provided), which will result in changed outlines and advance widths, and may potentially also apply region-specific OpenType Layout lookups through the Feature Variations facility (see the "FeatureVariations Table" in the chapter "OpenType Font Variations Common Table Formats").

JstfVariation table

Type Name Description
Offset16 coverageOffset Offset to Coverage table, from beginning of JsftVariation table (may be NULL)
uint16 axisID Variation axis to apply
uint16 flags Direction flags - see below

The following flags are defined.

Mask Name Description
0x0001 POSITIVE_IS_SHRINKAGE A positive change to the action reduces the glyph width.
0xFFFE Reserved Reserved for future use — set to 0.

If no flags are set, a positive change to the design space location is expected to produce expansion while a negative change is expected to produce shrinkage. (For example, in the case of a width or glyph extension axis.) If the POSITIVE_IS_SHRINKAGE flag is set, the rendering system will move in the opposite direction, seeking expansion by moving negatively along the specified axis. While there is no expectation that motion along the axis has a linear relationship to advance width, the font designer is responsible for ensuring that the rendering system is likely to locating the desired change in width by moving in the specified direction.

When the rendering system reaches the maximum or minimum value of the design space for the glyphs specified along the given axis but the line width does not come to the desired total, the rendering system moves on to the next priority level and tries additional expansion/shrinkage attempts.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment