Skip to content

FontFace

Mojo struct 🡭

FontFace

@memory_only
struct FontFace

One installed face: where its file is, what it calls itself, and the handful of style axes matching compares. Everything here comes out of the font’s own tables; nothing is inferred from the filename.

Fields

  • path (String): Absolute, symlink-resolved path to the font file.
  • names (List[String]): Every normalized name this face answers to – typographic family (name ID 16), legacy family (ID 1), full name (ID 4) and PostScript name (ID 6), deduplicated. A request matches the face if it equals any of them, which is how “DejaVu Sans” and “DejaVuSans-Bold” both find the same file.
  • weight (Int): OS/2 usWeightClass, 100..1000.
  • slant (Int): _SLANT_ROMAN/_SLANT_ITALIC/_SLANT_OBLIQUE.
  • width (Int): OS/2 usWidthClass, 1..9, 5 being normal width. Only a tie-break, but the one that keeps “Nimbus Sans Narrow” from outranking “Nimbus Sans” for a plain request.
  • monospace (Bool): post’s isFixedPitch, or PANOSE bProportion == 9.
  • renderable (Bool): Whether ttf.mojo can actually parse this file: glyf or CFF outlines or CBDT color bitmaps, and not a collection container it reads no face index from. False for every face in a .ttc. Ranked below every real matching term – an exact family match wins even when the answer is a font this library will then refuse, which is a clear error rather than a silently different font.
  • cmap_offset (Int): Absolute file offset of this face’s cmap table, -1 if it has none. Read lazily, only when a codepoint constraint is in play.
  • cmap_length (Int)

Implemented traits

AnyType, Copyable, Deinitable, Movable