GNOME Bugzilla – Bug 735732
Skip attributes inside elided text
Last modified: 2014-09-03 19:23:50 UTC
When we insert a run for the ellipsis in the layout, we are careful to preserve attributes of the elided text. This means that the run can have attributes which do not cover its full range, unlike 'normal' runs whose attributes always span the entire range. PangoRenderer was not paying attention to the ranges and just blindly applied all attributes it found. The effect of this is that the ellipsis in a label with links is blue and underlined even if the link is entirely contained in the elided text. Correct this ignoring applying attributes that begin after the start of the run.
Created attachment 284912 [details] [review] Skip attributes inside elided text
Review of attachment 284912 [details] [review]: I made Owen look at this for - the upshot is that pango_glyph_item_apply_attrs needs to be smarter instead, and avoid applying no-shape attributes whose range is wholly contained in the ellipsis run.
Created attachment 285210 [details] [review] PangoGlyphItem: Better treatment of ellipsized runs When we reapply non-shape attributes, we must take care to not add them inside ellipsized runs, or we end up with a blue, underlined ellipsis if there is a link anywhere inside the ellipsized text.
Note that even for normal runs the attributes do not necessarily expand the entire run. Underline is a good example, so is color.
Didn't review the patch too closely, but looks about right.
(In reply to comment #4) > Note that even for normal runs the attributes do not necessarily expand the > entire run. Underline is a good example, so is color. If thats the case, I don't understand how pango_renderer_default_prepare_run can get away with not looking at the ranges.
(In reply to comment #4) > Note that even for normal runs the attributes do not necessarily expand the > entire run. Underline is a good example, so is color. This is not the case - the whole idea of the code that this patch modifies is to split runs up after shaping to take attributes like color and underline into account. (As a consequence of the fact that attributes always apply to a run, an attribute can never apply to just one character in a cluster - try pango-view --font 32 --markup -t '<u>f</u>ile')
Ah, sorry, my bad. I should have said ideally attributes wouldn't apply to entire runs after we fix color/underlining parts of ligatures.
Review of attachment 285210 [details] [review]: ::: pango/pango-glyph-item.c @@ +547,3 @@ + gint range_end) +{ + /* Skip attributes that are wholly contained in an ellipsized run */ The rule that ellipsize.c uses is that the attributes applying to the ellipsis are the attributes applying to the *first character* in the ellipsized text. For me: pango-view --font 'Adwaita 32' --markup -t '<small>...small</small><big>Big</big><small>small...</small>' --ellipsize=middle --width 240 Shows this - the ellipsis is big while everything else is small. If we apply this rule here as well, we won't entirely fix the original problem, of course, since if the ellipsis starts *exactly* where the link starts, the ellipsis will be shown as a link. But it might be good enough - it's not *entirely* weird if: "Please go to our website _www.gnome.org_ for further details" gets ellipsized to "Please go to our website _..._" Better than the current situation where you can have: "Please _..._" and much less likely to be triggered. I *don't* think we want inconsistent rules, so we'd have to adjust ellipsize.c as well if we wanted to prevent this problem. If we're applying the existing rule, I think we just need to add "is_a_ellipsis || .." to: /* Short circuit the case when we don't actually need to * split the item */ if (range_start <= glyph_item->item->offset && range_end >= glyph_item->item->offset + glyph_item->item->length) goto out; We've found the range that includes the first character in the run, at that point, we should just copy it's attributes over to the item without splitting it.
Attachment 285210 [details] pushed as d23a0b0 - PangoGlyphItem: Better treatment of ellipsized runs