PDF rendering: Do not create TTFont if already cached (#5748)

This provides a massive speedup for invoice rendering
This commit is contained in:
Raphael Michel
2026-01-05 12:15:35 +01:00
committed by GitHub
parent 449b960438
commit bb5a9bdbf1
4 changed files with 39 additions and 32 deletions

View File

@@ -100,3 +100,11 @@ class FontFallbackParagraph(Paragraph):
if (original_font.endswith("Bd") or original_font.endswith(" B")) and "bold" in styles:
return family + " B"
return family
def register_ttf_font_if_new(name, path):
from reportlab.pdfbase import pdfmetrics
from reportlab.pdfbase.ttfonts import TTFont
if name not in pdfmetrics.getRegisteredFontNames():
pdfmetrics.registerFont(TTFont(name, path))