From 0dc12b6b30f825e63ee8992c46fffede837a9fcd Mon Sep 17 00:00:00 2001 From: Guillaume Ayoub Date: Fri, 30 Sep 2022 23:54:41 +0200 Subject: [PATCH] Cache add_font to avoid calling get_face too often --- weasyprint/pdf/stream.py | 2 ++ 1 file changed, 2 insertions(+) diff --git a/weasyprint/pdf/stream.py b/weasyprint/pdf/stream.py index dfe09884c2..617ee57365 100644 --- a/weasyprint/pdf/stream.py +++ b/weasyprint/pdf/stream.py @@ -2,6 +2,7 @@ import io import struct +from functools import lru_cache import pydyf from fontTools import subset @@ -310,6 +311,7 @@ def set_blend_mode(self, mode): 'BM': f'/{mode}', })) + @lru_cache def add_font(self, pango_font): pango_face = pango.pango_font_get_face(pango_font) if pango_face not in self._fonts: