Class FontEngine
Immutable font index + simple shaper for Word-compatible measurement over OpenType TTF/OTF/TTC sources.
public sealed class FontEngine : ITextShaper
- Inheritance
-
FontEngine
- Implements
- Inherited Members
Remarks
One engine instance is built once per converter instance and then used concurrently by many runs. The index is immutable after construction.
Constructors
- FontEngine(FontEngineOptions?, IConversionDiagnostics?)
Initializes a font engine from system directories, caller-provided directories, and optional embedded font payloads.
Properties
- FaceCount
Gets the number of indexed faces.
- HasScriptFallback
Gets a value indicating whether any per-script glyph-level fallback chains are configured (see ScriptFallbackFonts).
- IndexedSources
Gets the indexed source identifiers (paths / part names).
- Name
Gets the stable shaper identifier.
Methods
- CanShape(FontFace, string?)
Shapes Arabic and Hebrew through the face's own GSUB and GPOS tables - joining forms, required and standard ligatures, contextual alternates, marks and kerning - when the face has the tables, covers the script and maps the run's letters. Every other script, and every face that fails one of those tests, keeps the cmap + hmtx path byte for byte; a run the tables cannot shape (a malformed table, an exhausted work budget) falls back to it too, so shaping never turns into an exception.
- Measure(ReadOnlySpan<char>, FontFace, Twips, Twips, ClusterAdvanceBuffer)
Measures a run against an already resolved face into a reusable buffer.
- Measure(ReadOnlySpan<char>, in FontKey, Twips, IConversionDiagnostics?)
Measures a run with a logical font key and returns immutable per-cluster advances.
- Measure(ReadOnlySpan<char>, in FontKey, Twips, ClusterAdvanceBuffer, IConversionDiagnostics?)
Measures a run with a logical font key into a caller-provided reusable buffer.
- Parse(ReadOnlyMemory<byte>, string, IConversionDiagnostics?)
Parses one TTF/OTF/TTC payload into one or more FontFace instances.
- Preflight(IReadOnlyList<FontKey>)
Runs a font preflight over a set of requested families, returning one resolution per distinct family (first-seen order) plus aggregate substitution risk. This resolves without emitting per-run diagnostics so a caller can inspect fidelity risk before paying for a full conversion.
- Resolve(in FontKey, IConversionDiagnostics?)
Resolves a logical font request to a concrete face, applying Word-style fallback and synthetic bold/italic flags when exact styles are missing.
- Resolve(in FontKey, out FontResolution, IConversionDiagnostics?)
Resolves a logical font request and additionally reports the detailed resolution outcome (which step succeeded, the selected family, and a PANOSE distance or exact-metric flag for substitutions).
- Shape(in ShapeRequest, ShapedGlyphBuffer)
Shapes text through the ITextShaper seam using the provided FontFace implementation.
- TryGetFontProgram(FontFace, out ReadOnlyMemory<byte>)
Tries to get the font program backing a resolved face whose source is held in memory — a document-embedded payload or one of the bundled metric-compatible fonts — rather than stored as a file on disk.
- WithEmbeddedFonts(IList<EmbeddedFontSource>, IConversionDiagnostics?)
Returns an engine that resolves against this engine's faces plus the supplied document-embedded payloads, which take priority over everything already indexed.