Class FontSettings
Controls global font-loading behaviour for the drawing library. All properties must be set before the first access to Default because the system font collection is scanned once and cached for the lifetime of the process.
Inherited Members
Namespace: DRIT.Drawing.Text
Assembly: DRIT.Drawing.dll
Syntax
public static class FontSettings
Properties
AutoLoadSystemFonts
Gets or sets a value indicating whether InstalledFontCollection
automatically loads system fonts on first access. The default is true.
Declaration
public static bool AutoLoadSystemFonts { get; set; }
Property Value
| Type | Description |
|---|---|
| bool |
Remarks
When true (the default), Default
scans the platform font directories (and optionally native OS APIs) and loads
every discovered font. This is the expected behaviour for desktop and console
applications.
When false, Default contains only
the three generic fallback families (Sans Serif, Serif,
Monospace) with guessed metrics. Applications must load fonts manually
via PrivateFontCollection. This is recommended for web and server
scenarios where:
- Startup latency from scanning hundreds of system fonts is undesirable.
- The server/container has no system fonts installed.
- The application ships its own embedded fonts and wants deterministic behaviour.
- File-system access to font directories is restricted by sandboxing.
This property must be set before the first access to Default. Changes after the collection has been created have no effect.
UseNativeFontApis
Gets or sets a value indicating whether native operating-system APIs are used
for font discovery before falling back to directory scanning. The default is
true.
Declaration
public static bool UseNativeFontApis { get; set; }
Property Value
| Type | Description |
|---|---|
| bool |
Remarks
When true (the default), the library queries the platform's native font
service first:
- Windows: reads the font registry keys (
HKLM\SOFTWARE\Microsoft\Windows NT\CurrentVersion\Fontsand the per-user equivalent) to resolve family names to file paths, including fonts installed outside the standard%SYSTEMROOT%\Fontsdirectory. - macOS: queries CoreText (
CTFontManagerCopyAvailableFontFamilyNames) for the authoritative family list and file paths. - Linux: queries fontconfig (
FcConfigGetFonts) for the authoritative family list and file paths, respecting fontconfig aliases and non-standard install locations.
When false, only directory scanning of the standard font directories is
used. This avoids any P/Invoke to native libraries and is useful in restricted
environments where native library loading is prohibited.
This property has no effect when AutoLoadSystemFonts is false.