ddn.cti.text.font_face
ddn.cti.text.font_face — the face role.
A size-less parsed font: one face of one file. Opening, glyph lookup, the bytes it came from, design-scale metrics and a stable identity for caches. Everything scaled — pixel size, metrics at a size, raster, outlines — belongs to the font role (ddn, cti, text, font).
The reference is a template over the implementor's Self: open fills an out T and returns Status!TextError, the factory convention of doc/DDN-CTI.md section 9.1 (the original by-value factory failed the supported compiler's move-only feasibility check). An implementor is a struct mirroring this surface, proven by one static assert(isFontFace!MyType);.
Semantics the checker cannot enforce (doc/DDN-CTI.md section 9.2):
openparses the match'sbytesorpathand itsfaceIndex; the face retains or copies what it needs so the match may die first.BAD_FONTfor malformed bytes,IOfor unreadable paths,UNSUPPORTEDfor formats or face indices the implementor cannot handle.glyphIdreturnsGLYPH_NOTDEFfor uncovered code points —a success, not an error.
bytesandfaceIndexdescribe exactly the face that wasopened;
bytesis borrowed for the face's lifetime.unitsPerEmanddesignMetricsanswerUNSUPPORTEDratherthan invented values when the format carries no design scale;
glyphCountis always defined (a parsed face knows its glyphs).capabilitiesreports what the implementor can do for this face; a member answersfalse/UNSUPPORTEDrather than failing late when a capability is absent.identityis equal for two faces of the same bytes andindex; caches key on it.
- Lifetime: non-copyable, moved only; nothing outlives its
bytes. Thread safety: one thread at a time per face.
Inspiration: FreeType (FT_Face before FT_Set_Pixel_Sizes): opening from memory with a face index, FT_Get_Char_Index, FT_HAS_COLOR. Skia SkTypeface, cairo cairo_font_face_t, Blend2D BLFontFace, Core Text CGFont: the size-less face as its own object, and the face/font split this module and ddn.cti.text.font follow. DirectWrite IDWriteFontFace: a face that never carries a size. libschrift: the smallest implementor; it has no collections and no outlines, which is why capabilities exists, and no design-unit calls, which its adapter answers from the head table itself. HarfBuzz hb_face_create over a blob: the reason bytes exists, so any shaper can build its font object from any face.
Types 3
One optional capability of a face and its font role.
The capability set reported by FontFaceRef.capabilities.
Reference signatures of a font face over implementor T. Bodiless on purpose: never instantiated, only compared against with implements (through isFontFace).
Parameters
T | the implementor type (Self). |
string nameImplementor name for logs and conformance tables, e.g. `"freetype"`; empty in the reference.Status!TextError open(out T face, in FontMatch match) static @safe nothrow;Opens the face described by a match. The factory convention (`doc/DDN-CTI.md` section 9.1): the handle is filled through the `out` parameter and failure is a status.const(ubyte)[] bytes() return @safe nothrow @nogc const;The font file bytes the face was parsed from.uint faceIndex() @safe nothrow @nogc const;Returns: The index of this face within its collection, 0 for a single-face file.Result!(uint, TextError) unitsPerEm() @safe nothrow @nogc const;Returns: Font units per em (`head.unitsPerEm`), or `UNSUPPORTED` when the format carries no design scale — never an invented value.Result!(DesignMetrics, TextError) designMetrics() @safe nothrow @nogc const;Returns: Ascent, descent, line gap and glyph bounding box in font design units, or `UNSUPPORTED` when the format carries none.uint glyphCount() @safe nothrow @nogc const;Returns: The number of glyphs in the face (`maxp.numGlyphs`).FontCapabilities capabilities() @safe nothrow @nogc const;Returns: The features this implementor provides for this face: `COLOR` when `Font.rasterize` with `ARGB32` produces colour, `OUTLINES` when `Font.glyphOutline` works, `HINTING` when `FontOptions.hi...ulong identity() @safe nothrow @nogc const;Returns: A key equal for two faces of the same bytes and index; what caches key on.