GNOME Bugzilla – Bug 147608
Customizing ellipsization behavior
Last modified: 2018-05-22 12:05:35 UTC
There is likely a need to allow the exact details of pango_layout_set_ellipsize() to be customized by the application. For example, when ellipsizing a filename we might want to ellipsize before the basename rather than at the very end. - Add another PangoLogAttr for "allowed ellipsization position" to replace the - Add whatever framework we need to add anyways to allow customizing break positions. - Change the ellipsization algorithm to deal with the case where no ellipsization is allowed at the very start/end. (find_initial_span() and remove_one_span() need to be made a bit more complex)
Another example mentioned recently was the desire to ellipsise just a long filename embedded in an error message: The file .../foo/bar/baz.txt can't be read.
How would we expose this functionality to PangoLayout API users? We have to consider that we may not just allow to ellipsize at a single position, but constraint the collated text range, and the position where collation begins. The PANGO_ELLIPSIZE_MIDDLE API is quite poor in this context. I think we have some very specific use-cases: (1) ellipsize URI: file:///foo/bar/somefile.txt => file:///../somefile.txt (2) ellipsize paths: /foo/bar/somefile.txt => /../somefile.txt [mainly used for file operation error messages] (3) ellipsize basename: somefile.txt => some... .txt [mainly used by file managers for displaying file names] (4) ... Do you have any idea for other use-cases? Considering (1)-(3) suggests that we want complex but very specific ellipsization strategies. So we have two approaches: (A) Expose generic ellipsization markup: <span ellipsize_positon="start|end">...</span> [essentially replacing PANGO_ELLIPSIZE_MIDDLE] (B) Expose filename specific markup: <span ellipsize_style="uri|filename|basename">...</span> (A) A generic and developer-friendly approach would be to expose a PangoAttribute for this that operates on text ranges, that is wrapped to markup: Markup Example 1 (Full URI): This is an error message concerning file://<span ellipsize_position="start">full-path</span>/myfilename.txt which would ellipsize to file://full-p.../myfilename.txt or file://.../myfilename.txt depending on the available space. Markup Example 2 (basename): <span ellipsize_position="end">myfilename</span>.txt [to be used for Nautilus]. Again: These semantics would basically replace PANGO_ELLIPSIZE_MIDDLE. (B) Even more (file-related) developer friendly is a tag like Markup Example 1 (URI) <span ellipsize_style="uri">file://full-path/myfilename.txt</span> Markup Example 2 (basename) <span ellipsize_style="basename">myfilename.txt</span> These would be resolved to (A).1 and (A).2. best regards, Christian
Humm, I'm not sure I like replacing _MIDDLE. What I was thinking about was adding some attribute to mark certain parts of text as good places for ellipsis boundary, or disallowing ellipsization inside some parts. All that requires a much more sophisticated ellipsization algorithm than what we have now. I'll start thinking about it after I finish the pango_layout_set_height() mess I created.
I've reported bug 549729 on implementing an ellipsization scheme that would automatically ellipsize the non-unique parts of a string in a set of strings.
-- GitLab Migration Automatic Message -- This bug has been migrated to GNOME's GitLab instance and has been closed from further activity. You can subscribe and participate further through the new bug through this link to our GitLab instance: https://gitlab.gnome.org/GNOME/pango/issues/16.