Skip to content

Commit

Permalink
Cache add_font to avoid calling get_face too often
Browse files Browse the repository at this point in the history
  • Loading branch information
liZe committed Sep 30, 2022
1 parent dfccf1b commit 0dc12b6
Showing 1 changed file with 2 additions and 0 deletions.
2 changes: 2 additions & 0 deletions weasyprint/pdf/stream.py
Expand Up @@ -2,6 +2,7 @@

import io
import struct
from functools import lru_cache

import pydyf
from fontTools import subset
Expand Down Expand Up @@ -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:
Expand Down

0 comments on commit 0dc12b6

Please sign in to comment.