From d2278aee69f94a6be6252467fc3c52b415a77958 Mon Sep 17 00:00:00 2001 From: Guillaume Ayoub Date: Mon, 13 Jan 2020 23:48:51 +0100 Subject: [PATCH] =?UTF-8?q?Don=E2=80=99t=20insert=20the=20same=20layout=20?= =?UTF-8?q?attributes=20multiple=20times?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Using pango_attr_list_change is slower, but it prevents spacing attributes to be set twice, breaking the line-splitting algorithm for some reason. I don’t know if it is possible to add a simple test for that. Fix #1025. --- weasyprint/text.py | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/weasyprint/text.py b/weasyprint/text.py index fd0798a88..28eb5ee53 100644 --- a/weasyprint/text.py +++ b/weasyprint/text.py @@ -205,6 +205,8 @@ void pango_attr_list_unref (PangoAttrList *list); void pango_attr_list_insert ( PangoAttrList *list, PangoAttribute *attr); + void pango_attr_list_change ( + PangoAttrList *list, PangoAttribute *attr); PangoAttribute * pango_attr_font_features_new (const gchar *features); PangoAttribute * pango_attr_letter_spacing_new (int letter_spacing); void pango_attribute_destroy (PangoAttribute *attr); @@ -776,7 +778,7 @@ def add_attr(start, end, spacing): # TODO: attributes should be freed attr = pango.pango_attr_letter_spacing_new(spacing) attr.start_index, attr.end_index = start, end - pango.pango_attr_list_insert(attr_list, attr) + pango.pango_attr_list_change(attr_list, attr) add_attr(0, len(bytestring) + 1, letter_spacing) position = bytestring.find(b' ')