JFLib

text/cff.rs#

Source: lib/text/cff.rs

cff -- CFF and CFF2 ('CFF ' / 'CFF2' tables of OpenType fonts): Type 2 charstrings -> cubic
outlines                                                               [src/text/cff.s]

  Cff::open(table, upem) -> context / ERR_*   CFF: the header, Top DICT, CharStrings, global
       and local subrs, CID-keyed FDArray / FDSelect (formats 0 and 3), FontMatrix
  Cff::open2(table, upem) -> context / ERR_*  CFF2: the header and the Top DICT right after
       it (no Name / String INDEX), INDEXes with 32-bit counts, CharStrings, global subrs,
       FDArray (each font DICT's Private DICT: Subrs and vsindex; blend in its values),
       FDSelect (formats 0, 3 and 4; none: font DICT 0), the VariationStore (vstore),
       maxstack, FontMatrix
  outline(table, glyph, ol) -> false on error   run the charstring, points into the outline
       buffer (OLT_ON / OLT_CUBIC, font units)
  outline_var(table, glyph, coords, ol)   the same at a CFF2 instance's normalized
       coordinates (F2Dot14 per axis, avar applied: var.rs normalize; empty = the default)
  outline_seac(table, glyph, ol) -> (ok, seac)   outline, and the accent of an endchar with
       four arguments (adx, ady, bchar, achar: the base and the accent by StandardEncoding
       code, the accent moved by adx, ady before the FontMatrix), for a caller that has the
       glyph names (a font of a PDF file: the CFF charset)
  matrix() -> the FontMatrix scaled to the units of the outline (None: none or 1/upem)

Type 2 operators: all path operators (r/h/v moveto, lineto, rrcurveto, hh/vv/hv/vh curveto,
rcurveline, rlinecurve, flex, hflex, hflex1, flex1), hint operators (stems are counted for
hintmask / cntrmask and skipped), callsubr / callgsubr (bias 107 / 1131 / 32768, nesting
<= 10), return, endchar (a seac accent is not drawn: outline_seac reports it), the
arithmetic / storage operators (abs add sub div neg eq drop put get ifelse random mul sqrt
dup exch index roll and or not).  Argument stack 48, transient array 32, at most 200000 operators per glyph, at most
256 font DICTs, a Private DICT read to at most 64 KiB.  The
width argument is dropped (advances come from hmtx).  Like the assembly, the transient
array and the random generator are process-wide.

CFF2 charstrings: no width argument, no endchar (the charstring ends with its data, a subr
too; return and endchar are still accepted, as are the arithmetic operators, like FreeType),
vsindex (before the first blend; else the Private DICT's, default 0) and blend: n values,
n x k deltas, n -> the n values default + sum(delta x scalar), k = the regions of that item
variation data, their scalars at coords (var.rs ivs_scalars: HarfBuzz's region rules, f32).
Argument stack maxstack (default 193, here 193 ..= 513), at most 512 regions per item
variation data, a vsindex after a blend is an error.  Advances come from hmtx + HVAR
(ttf.rs); hints are skipped (CFF2 outlines are not hinted, like CFF ones).
  • struct Cff

impl Cff

  • fn is_v2(&self) -> bool a CFF2 table (its outline() takes normalized coordinates)
  • fn varies(&self) -> bool a CFF2 table with a variation store: its outlines vary
  • fn open(t: Tb, upem: u32) -> Result<Cff, i32> cff_open: ERR_HDR (malformed) / ERR_UNSUPPORTED (not CFF 1 / not Type 2 charstrings)
  • fn open2(t: Tb, upem: u32) -> Result<Cff, i32> cff2_open: ERR_HDR (malformed) / ERR_UNSUPPORTED (not CFF2)
  • fn outline(&self, t: Tb, glyph: u32, ol: &mut Outline) -> bool run the charstring of glyph into the outline buffer: false = malformed [cff_outline]
  • fn outline_var(&self, t: Tb, glyph: u32, coords: &[i16], ol: &mut Outline) -> bool outline at a CFF2 instance's normalized coordinates (empty: the default instance; CFF ignores them)
  • fn outline_seac(&self, t: Tb, glyph: u32, ol: &mut Outline) -> (bool, Option<[f32; 4]>) outline, and the accent of a seac endchar: (adx, ady, bchar, achar)
  • fn matrix(&self) -> Option<[f32; 6]> the FontMatrix in the units of the outline (applied to it already): None when the font has none or it is 1/unitsPerEm

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