Measurements format

A data format to store definitions of font-level and glyph-level measurements.

Data structure

A measurement establishes a link between two points and returns the distance between them.

The order of the points matters: a measurement can be positive or negative.

Font-level measurements

attribute description  
name name of the measurement required
glyph 1 name of the glyph containing the 1st measurement point required
point 1 index or shortcut of 1st measurement point required
glyph 2 name of the glyph containing the 2nd measurement point required
point 2 index or shortcut of 2nd measurement point required
direction direction of measurement required
parent parent measurement optional
description description of this measurement optional

Glyph-level measurements

attribute description
name name of the measurement
point 1 index or name of 1st measurement point
point 2 index or name of 2nd measurement point
direction direction of measurement

Direction keys

The direction of measurement must be one of the following characters:

characters description
x horizontal measurement
y vertical measurement
a angled measurement

The order of the points in a measurement matters: the sign of the measured value indicates its direction. Some measurements are by definition negative, for example the descender value or a bottom overshoot.

Point IDs

Points can be identified by a number (point index) or a letter (reference point).

Point indexes

Contour points are identified by their index (an integer).

Reference points

Font-level vertical metrics are also available using the following shortcut characters:

character description y-position
A ascender font.info.ascender
B baseline 0
C cap height font.info.capHeight
D descender font.info.descender
X x-height font.info.xHeight

Python example

Font-level measurements

The key for font-level measurements is the name of the measurement.

fontMeasurements = {
    'XTUC' : {
        'glyph 1'   : 'H',
        'point 1'   : 11,
        'glyph 2'   : 'H',
        'point 2'   : 8,
        'direction' : 'x',
        'parent'    : 'XTRA',
    },
    # more font-level measurements here ...
}

Glyph-level measurements

The key for glyph-level measurements is an identifier created from the two point IDs.

glyphMeasurements = {
    "a" : {
      f'{ptID1} {ptID2}' : {
          'name'      : 'XTRA',
          'direction' : 'x',
      },
      # more glyph-level measurements here ...
    },
    # more glyphs here ...
}

JSON format

Measurements can be stored in standalone JSON files using the format below.

The same set of measurement definitions can be used to measure all sources in a designspace.

{
  "font": {
    "XTUC": {
      "direction": "x",
      "glyph 1": "H",
      "point 1": "11",
      "glyph 2": "H",
      "point 2": "8",
      "parent": "XTRA"
    },
    /* more font-level measurements here ... */
  },
  "glyphs": {
    "n": {
      "0 20": {
        "direction": "x",
        "name": "XOLC"
      },
      "11 12": {
        "direction": "x",
        "name": "XOLC"
      },
      "13 19": {
        "direction": "x",
        "name": "XTLC"
      },
      /* more glyph-level measurements here ... */
    },
    /* more glyphs here ... */
  },
}