Class HarfBuzzTextShaper
- Namespace
- DocWright.ComplexText
- Assembly
- DocWright.ComplexText.dll
HarfBuzz-backed ITextShaper implementation for complex scripts.
public sealed class HarfBuzzTextShaper : ITextShaper
- Inheritance
-
HarfBuzzTextShaper
- Implements
- Inherited Members
Remarks
HarfBuzz shapes from the font program itself, so the shaper has to get from the FontFace it is handed back to that program's bytes. A face indexed from a font directory names a file, which HarfBuzz maps. A face that came from a document-embedded payload or from the fonts bundled with DocWright has no file; its bytes are held in memory and are handed to HarfBuzz from there. Where neither exists — a face produced by Parse(ReadOnlyMemory<byte>, string, IConversionDiagnostics?) under a name that is not a path — there is nothing to shape from, and the run is laid out from the face's character map and advance widths alone.
The glyph ids and advances returned are drawn and measured against the face DocWright parsed, and HarfBuzz parses the same bytes again with a reader and a sanitizer of its own. A table its sanitizer refuses does not fail; it reads as empty, and the run comes back as glyph 0 throughout, or with no advances, or with advances scaled by the wrong em. An in-memory program is therefore held to the face, run by run: every character must be, in HarfBuzz's reading, the glyph the face draws it with, at the same advance width. Where it is not, HarfBuzz is not reading the font the face came from, and that run is laid out from the face's character map and advance widths, which is how every embedded and bundled face was laid out before this shaper could reach their bytes.
An instance is safe to share between threads and between conversions. The only state it keeps is the in-memory programs of the faces it has shaped, each held for as long as the font engine that indexed its face is alive and no longer.
Constructors
Properties
- Name
Gets the stable shaper identifier, for example "simple".