Skip to content

Commit

Permalink
Merge pull request #2149 from Kozea/fix-font-cache
Browse files Browse the repository at this point in the history
Don’t cache Pango fonts
  • Loading branch information
liZe committed May 6, 2024
2 parents 0484ffd + bd9bca2 commit 195a529
Showing 1 changed file with 4 additions and 2 deletions.
6 changes: 4 additions & 2 deletions weasyprint/text/fonts.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
"""Interface with external libraries managing fonts installed on the system."""

from functools import lru_cache
from hashlib import md5
from io import BytesIO
from pathlib import Path
Expand Down Expand Up @@ -389,9 +388,12 @@ def get_hb_object_data(hb_object, ot_color=None, glyph=None):
return data


@lru_cache()
def get_pango_font_key(pango_font):
"""Get key corresponding to given Pango font."""
# TODO: This value is stable for a given Pango font in a given Pango map, but can’t
# be cached with just the Pango font as a key because two Pango fonts could point to
# the same address for two different Pango maps. We should cache it in the
# FontConfiguration object. See https://github.com/Kozea/WeasyPrint/issues/2144
description = ffi.gc(
pango.pango_font_describe(pango_font),
pango.pango_font_description_free)
Expand Down

0 comments on commit 195a529

Please sign in to comment.