Add BuildFontsAsync for parallel font/theme init

This commit is contained in:
2026-05-08 20:34:05 +02:00
parent daa800c8b1
commit ccc5a4e17a
2 changed files with 15 additions and 3 deletions
+13
View File
@@ -100,6 +100,19 @@ public class FontManager
JpRange = BuildRange(GlyphRangesJapanese.GlyphRanges);
}
/// <summary>
/// Async wrapper around <see cref="BuildFonts"/> for the Phase-1 LoadAsync
/// path. The font-atlas build is CPU-bound, so we offload via Task.Run and
/// honour the cancellation token at the scheduling boundary; this lets the
/// font build run in parallel with the theme init without blocking the
/// loader. Settings-driven manual rebuilds keep using the sync entry point.
/// </summary>
public async Task BuildFontsAsync(CancellationToken cancellationToken)
{
cancellationToken.ThrowIfCancellationRequested();
await Task.Run(BuildFonts, cancellationToken).ConfigureAwait(false);
}
public void BuildFonts()
{
SetUpRanges();