Table of Contents

Method WithEmbeddedFonts

Namespace
DocWright.Fonts
Assembly
DocWright.Fonts.dll

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.

public FontEngine WithEmbeddedFonts(IList<EmbeddedFontSource> embeddedFonts, IConversionDiagnostics? diagnostics = null)

Parameters

embeddedFonts IList<EmbeddedFontSource>

The embedded font payloads to add.

diagnostics IConversionDiagnostics

The diagnostics sink, or null to discard diagnostics.

Returns

FontEngine

A derived engine, or this engine unchanged when embeddedFonts is empty.

Remarks

Indexing the system font directories costs roughly a second, and it produces the same result for every document. This method reuses that work: the derived engine shares the parsed face index, the metric-compatibility map, the fallback chain and the script fallback tables, and only the embedded payloads are parsed afresh.

The alternative — building a whole engine per distinct embedded set — was rejected because it optimizes the wrong half of the cost: a service converting a thousand documents with different embedded fonts would pay a thousand seconds of pure system-font indexing for payloads that are a few kilobytes each.

The derived engine keeps its own resolution cache. Resolution results legitimately differ between an engine that has a document's embedded fonts and one that does not, so sharing the cache would leak one document's font resolution into another's.

An empty list returns this, so a document with no embedded fonts takes a path indistinguishable from having never called the method.

Exceptions

ArgumentNullException

embeddedFonts is null.