JFLib

text/var.rs#

Source: lib/text/var.rs

var -- OpenType font variations: fvar (axes, named instances), avar (segment maps), gvar
(TrueType point deltas), HVAR (advance deltas), MVAR (font-wide metrics) and the item
variation store HVAR, MVAR and GDEF share

  VarAxis { tag, min, def, max, hidden, name }, VarInstance { name, coords }   what fvar
       says, in user units; names from the name table (an axis without one: its tag)
  Var::parse(tables) -> Option<Var>  a font's fvar, avar, gvar, HVAR, MVAR, GDEF store
  normalize(user) -> coords          F2Dot14 per axis: clamped to the axis, -1 .. 0 .. 1
       around the default in 16.16, avar in 16.16, then 2.14 (rounded like HarfBuzz and
       FreeType: floor(x + 0.5))
  gvar_deltas(gvar, glyph, coords, orig, ends, out, budget)   the deltas of a glyph's points
       and of its 4 phantom points, added to out: embedded and shared peak tuples,
       intermediate regions, shared and private packed point numbers, packed deltas (zero
       runs, bytes, words, longs), IUP for the outline points a tuple leaves out
  hvar_delta(hvar, glyph, coords)    the advance delta (HVAR, with or without its mapping)
  mvar_delta(mvar, tag, coords)      a font-wide metric's delta (MVAR)
  gdef_delta(gdef, outer, inner, coords)   a GPOS VariationIndex delta (GDEF's store)
  ivs_scalars(t, store, outer, coords, max, out), ivs_region_count(t, store, outer)   CFF2
       (cff.rs): the region scalars of one item variation data for blend, its region count
       for a Private DICT's blend

Every offset is checked against its table (gvar data against the glyph's own range).
Broken gvar data of a glyph: false (the glyph comes out empty, like broken glyf data);
broken HVAR / MVAR / store data: no delta.  Bounded work: a glyph whose tuples x points
exceed VAR_BUDGET counts as broken; a store row whose regions x axes exceed IVS_WORK has
no delta (a CFF2 blend: the glyph is broken).  CFF2 outlines vary through cff.rs's blend at
the same coordinates (advances: hmtx + HVAR).  Not supported: avar version 2 beyond its
segment maps, VVAR (no vertical layout).
/// axes and named instances read at most
AXES_MAX: usize = 64
INSTANCES_MAX: usize = 1024
  • struct VarAxis an axis of a variable font (fvar) in user units (min <= def <= max)

    • tag: [u8; 4] -- wght, wdth, slnt, ital, opsz or one of the font's own
    • min: f32 -- the smallest value
    • def: f32 -- the default (the font's own outlines)
    • max: f32 -- the largest value
    • hidden: bool -- the font asks user interfaces not to show it (HIDDEN_AXIS)
    • name: String -- the name table's name (UTF-8; the tag when there is none)
  • struct VarInstance a named instance of a variable font (fvar)

    • name: String -- its subfamily name ("SemiLight Condensed"; "" when the name table has none)
    • coords: Vec<f32> -- user coordinates, one per axis
  • const fn tag_u32(t: [u8; 4]) -> u32 a 4-byte tag as the u32 of the font file

Source: docs/API.md in the JFLib repository.