ddn.cti.text.types
ddn.cti.text.types — shared value types of the text roles.
The values that flow between a FontSource, a FontFace, a Font, a Shaper and a BidiResolver (ddn, cti, text), including a retaining lease for optional native fast paths. No font-library binding or role implementation lives here; every implementor and consumer agrees on one vocabulary. Names follow the study's owner-approved naming table (CTI-TEXT-LANDSCAPE.md section 7, adjusted paths).
Metrics and positions use the 26.6 binary fixed point (Fixed26_6, re-exported from ddn.num.fixed_binary) of FreeType and HarfBuzz: advances, bearings and bitmap geometry are exact at 1/64th of a pixel. Design metrics are unscaled font units.
Errors at the role boundaries are Result/Status values over TextError, never exceptions, and carry bounded, allocation-free diagnostic metadata so hot paths never allocate for failure reporting (doc/DDN-CTI.md section 9.3).
Inspiration: FreeType (FT_Glyph_Metrics, FT_Size_Metrics, FT_Bitmap): the advance/bearing/box metric set and the 26.6 unit. HarfBuzz (hb_glyph_info_t, hb_glyph_position_t): the shaped glyph with a cluster index and four positioning values. DirectWrite (DWRITE_GLYPH_METRICS, DWRITE_GLYPH_RUN): the same metric vocabulary in a COM API; MapCharacters' covered length shape recorded on FontMatch. OpenType (head, hhea, maxp, fvar): design units per em, the design metrics fields and 16.16 variation coordinates. PostScript/SVG path vocabulary: the five outline commands of OutlineSink.
Types 19
A glyph index within a font face. Glyph 0 is .notdef, the glyph a face draws for code points it does not cover.
Base direction of a text run: left to right or right to left.
An ISO 15924 script tag ("Latn", "Cyrl", "Arab"). The default "Zzzz" is the ISO code for an uncoded (unknown) script; a shaper may derive the script from the text when it sees the default.
char[4] tagThe four-letter ISO 15924 code.A BCP 47 language tag ("en", "sr-Latn"). The empty tag means "unspecified".
string tagThe BCP 47 tag; empty when unspecified.One OpenType feature setting of a text run, e.g. liga = 0 to disable standard ligatures. Features are requests: an implementor honours what it can and reports the rest in its conformance table.
char[4] tagThe four-character OpenType feature tag (`"kern"`, `"liga"`).uint valueThe feature value (0 disables a boolean feature).Common weight values of the CSS/OpenType 1..1000 scale.
Slant of a font.
Width of a font, narrowest to widest.
What an application asks a FontSource for.
string[] familiesFamily names in preference order ("DejaVu Sans", ...); empty means "any family".ushort weightWeight on the CSS/OpenType scale 1..1000 (400 regular, 700 bold).FontSlant slantSlant.FontWidth widthWidth (condensed .. expanded).uint pixelSizeNominal pixel size as a matching hint; 0 means "any".Language languageContent language, for language-sensitive matching.A copyable, reference-counted native lease for an optional same-provider fast path. Each copy retains the same context; its disposer runs exactly once, on the thread releasing the last copy. No registry or virtual calls.
The tag is the TypeInfo identity of a provider-defined tag type, not a collision-prone name hash. An unrelated provider gets null from get and must use portable bytes/path. The adopter must retain all native parents needed by the context, so the source may die while a match retains its lease.
Adoption allocates a small C-heap control block; copies, assignment and destruction allocate nothing. The context must contain no unrooted D GC references: the C-heap control block is not scanned by the GC. Adoption and raw access are deliberately @system ownership boundaries. Valid leases can be copied and destroyed in @safe nothrow @nogc code. They are thread-confined (including const views); this is not an atomic cross-thread shared pointer.
ProviderHandle opAssign(T)(auto ref T other) if (is(T == ProviderHandle) || is(T == const(ProviderHandle))
|| is(T == immutable(ProviderHandle))) ref return @trusted nothrow @nogcRetain-before-release assignment, including qualified sources and self-assignment. No allocation is needed. Params: other = replacement lease, which may be const or a temporary. Returns: this lease...Status!TextError adopt(Tag)(ref ProviderHandle destination, void * context,
Release release) if (is(Tag == struct)) static @system nothrow @nogcAdopts one owned native reference, tagged by a provider-defined type. The caller owns context on failure and transfers it on success. Replacing a destination releases its previous lease, unlike an ...bool belongsTo(Tag)() if (is(Tag == struct)) const @trusted nothrow @nogcTests whether this lease belongs to a provider's tag type. Params: Tag = provider-defined identity type. Returns: false for empty leases or a different provider.this(ref return scope inout(ProviderHandle) other)Retains a lease while preserving the copy's qualifiers. Params: other = existing lease on the same thread.~thisReleases the native context when this is the last owner.StateOne C-allocated, provider-tagged shared ownership record.How a font was found: portable owned bytes or path, a face index, the resolved description, a stable identity and an optional same-provider retaining lease. Exactly one of path and bytes is set.
string pathFont file path; empty when `bytes` is set.const(ubyte)[] bytesOwned in-memory font bytes; empty when `path` is set. Owned by the match: stable for the match's lifetime.uint faceIndexFace index within a font collection (TTC); 0 otherwise.FontDescription descriptionThe description this match resolved to (family, style, weight as the source found them, which may differ from the request).ulong identityKey equal for two matches of the same face; what caches key on.ProviderHandle providerHandleOptional same-provider retaining lease; empty when absent.Face-wide metrics in unscaled font design units (the hhea quantities at the design scale, before any pixel size).
int ascentTypographic ascent in design units (positive upwards).int descentTypographic descent in design units (negative downwards).int lineGapAdditional line spacing in design units.int xMinGlyph bounding box, minimum x in design units.int yMinGlyph bounding box, minimum y in design units.int xMaxGlyph bounding box, maximum x in design units.int yMaxGlyph bounding box, maximum y in design units.Per-glyph metrics at a Font's pixel size, in 26.6 pixels.
Fixed26_6 xAdvanceHorizontal advance to the next glyph origin.Fixed26_6 yAdvanceVertical advance (vertical layouts).Fixed26_6 xBearingHorizontal bearing: origin to the left edge of the bitmap box.Fixed26_6 yBearingVertical bearing: origin to the top edge of the bitmap box.Fixed26_6 widthBitmap box width.Fixed26_6 heightBitmap box height.Pixel format of a rasterised glyph bitmap. The channel order is part of the contract, never implied by the platform:
A8— one coverage byte per pixel.A1— one coverage bit per pixel, most significant bitfirst, rows padded to whole bytes.
ARGB32— four bytes per pixel, in memory order B, G, R, A(the little-endian word
0xAARRGGBB), for colour glyph faces; colour channels are premultiplied by alpha. A face withoutFontCapability.COLORhas no ARGB32 output; a success never substitutes formats silently.
The geometry of one rasterised glyph and the caller buffer it needs. Returned by Font.rasterize; the pixels themselves live in the caller's buffer, never in this struct.
size_t requiredBytes the raster needs. When `required` exceeds the caller's buffer nothing is written; otherwise `outBuf[0 .. required]` holds the pixels.BitmapFormat formatThe format written — always the requested one on success.uint widthWidth in pixels.uint heightHeight in pixels.uint strideBytes per row (`A1` rows are whole bytes).Fixed26_6 xBearingOrigin to the left edge of the bitmap box, 26.6.Fixed26_6 yBearingOrigin to the top edge of the bitmap box, 26.6.Receiver of one glyph's outline commands, in 26.6 pixels at the Font's pixel size. The command vocabulary is the path vocabulary of PostScript, SVG, Skia, cairo and Blend2D. An empty outline is valid and simply invokes nothing.
void delegate(Fixed26_6 cx, Fixed26_6 cy, Fixed26_6 x, Fixed26_6 y) @safe nothrow quadToAdds a quadratic segment through control point (`cx`, `cy`) to end point (`x`, `y`).void delegate(Fixed26_6 c1x, Fixed26_6 c1y, Fixed26_6 c2x, Fixed26_6 c2y,
Fixed26_6 x, Fixed26_6 y) @safe nothrow cubicToAdds a cubic segment through control points (`c1x`, `c1y`) and (`c2x`, `c2y`) to end point (`x`, `y`).void delegate() @safe nothrow closeCloses the current subpath back to its start.Failure codes of the text roles (doc/DDN-CTI.md section 9.3).
A text-role failure: a code plus bounded, allocation-free diagnostic metadata. The detail is copied into a fixed buffer so hot error paths never allocate; providers that have nothing to add pass the code alone.
TextErrorCode codeWhich failure happened.this(TextErrorCode code, const(char)[] detail = null)Builds an error with optional detail.Variables 1
GLYPH_NOTDEF = 0The .notdef glyph id: FontFace.glyphId returns it for code points the face does not cover.