Skip to content

Commit 0dc12b6

Browse files
committed
Cache add_font to avoid calling get_face too often
1 parent dfccf1b commit 0dc12b6

File tree

1 file changed

+2
-0
lines changed

1 file changed

+2
-0
lines changed

weasyprint/pdf/stream.py

+2
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22

33
import io
44
import struct
5+
from functools import lru_cache
56

67
import pydyf
78
from fontTools import subset
@@ -310,6 +311,7 @@ def set_blend_mode(self, mode):
310311
'BM': f'/{mode}',
311312
}))
312313

314+
@lru_cache
313315
def add_font(self, pango_font):
314316
pango_face = pango.pango_font_get_face(pango_font)
315317
if pango_face not in self._fonts:

0 commit comments

Comments
 (0)