feat: add external drawing boxes and paged callbacks
CI / build-and-test (push) Canceled after 0s

This commit is contained in:
2026-08-31 22:10:06 +02:00
parent 3e5f197bdb
commit e2e2bfb854
10 changed files with 534 additions and 25 deletions
@@ -0,0 +1,29 @@
using System.Security.Cryptography;
using QuestPDF.Drawing;
namespace LehrerApp.Templating;
/// <summary>
/// Registers application-supplied TTF/OTF font bytes for TEXT and drawing commands without
/// exposing QuestPDF types to the calling application.
/// </summary>
public static class DrawingFontRegistry
{
private static readonly object Gate = new();
private static readonly HashSet<string> Registered = new(StringComparer.Ordinal);
public static void RegisterFont(string familyName, byte[] fontData)
{
if (string.IsNullOrWhiteSpace(familyName) || familyName.Length > 80)
throw new ArgumentException("Der Schriftname fehlt oder ist zu lang.", nameof(familyName));
if (fontData.Length is 0 or > 20 * 1024 * 1024)
throw new ArgumentException("Eine Schriftdatei muss zwischen 1 Byte und 20 MB groß sein.", nameof(fontData));
var key = familyName + ":" + Convert.ToHexString(SHA256.HashData(fontData));
lock (Gate)
{
if (!Registered.Add(key)) return;
using var stream = new MemoryStream(fontData, writable: false);
FontManager.RegisterFontWithCustomName(familyName, stream);
}
}
}