1
1
mirror of https://github.com/Kozea/WeasyPrint.git synced 2024-10-05 00:21:15 +03:00

Use Pango font description to get font hash

The hb_face value is different when the Pango font is different, and it causes
problems when multiple Pango contexts are used (for example when pages from
multiple documents are mixed).

Related to #551.
This commit is contained in:
Guillaume Ayoub 2021-02-01 22:38:27 +01:00
parent 8967a387d4
commit 631de1ba8c

View File

@ -234,6 +234,7 @@ ffi.cdef('''
PangoFontDescription * pango_font_describe (PangoFont *font);
const char * pango_font_description_get_family (
const PangoFontDescription *desc);
int pango_font_description_hash (const PangoFontDescription *desc);
PangoContext * pango_context_new ();
PangoContext * pango_font_map_create_context (PangoFontMap *fontmap);
@ -1335,8 +1336,10 @@ def show_first_line(context, textbox, text_overflow, x, y):
# Font content
pango_font = glyph_item.item.analysis.font
pango_font_description = pango.pango_font_describe(pango_font)
font_hash = pango.pango_font_description_hash(pango_font_description)
hb_font = pango.pango_font_get_hb_font(pango_font)
font_hash = hb_face = harfbuzz.hb_font_get_face(hb_font)
hb_face = harfbuzz.hb_font_get_face(hb_font)
fonts = context.get_fonts()
if font_hash in fonts:
font = fonts[font_hash]