Class SystemFontResolver
- Namespace
- NetPdf
- Assembly
- NetPdf.dll
IFontResolver backed by a process-wide system-font index. Resolves
CSS-generic family names (serif, sans-serif, monospace,
cursive, fantasy, system-ui) by walking a per-platform fallback
chain of known family names; for non-generic queries, looks up the family directly
in the index built from the OS's font directories.
public sealed class SystemFontResolver : IFontResolver
- Inheritance
-
SystemFontResolver
- Implements
- Inherited Members
Remarks
Lazy index build. Indexing every system font is non-trivial (parsing every
TTF in /System/Library/Fonts takes tens of milliseconds on warm cache,
hundreds cold). The index is built lazily on the first ResolveAsync(FontQuery, CancellationToken)
call; tests that don't touch this resolver pay nothing.
CSS-generic mapping. The fallback chains target the families NetPdf's three production platforms ship out of the box. They follow the same approach Chromium / WebKit / Gecko use for their default generic-family substitution tables, generalized to the macOS / Windows / Linux trinity.
Custom resolvers. Callers wanting full control should implement IFontResolver directly and either delegate to SystemFontResolver for fallback or skip system-font resolution entirely (e.g. shipping bundled fonts).
Constructors
SystemFontResolver()
Construct a resolver that lazily builds an index from the current platform's font directories.
public SystemFontResolver()
Methods
ResolveAsync(FontQuery, CancellationToken)
Return a font face matching query, or null if no match is
available — the next entry in the fallback chain will be tried.
public ValueTask<FontFaceData?> ResolveAsync(FontQuery query, CancellationToken ct)
Parameters
queryFontQueryctCancellationToken