Skip to content

Commit

Permalink
Don’t insert the same layout attributes multiple times
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
liZe committed Jan 13, 2020
1 parent cb610e8 commit d2278ae
Showing 1 changed file with 3 additions and 1 deletion.
4 changes: 3 additions & 1 deletion weasyprint/text.py
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down Expand Up @@ -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' ')
Expand Down

0 comments on commit d2278ae

Please sign in to comment.