Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Don’t cache Pango fonts #2149

Merged
merged 1 commit into from
May 6, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
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