GNOME Bugzilla – Bug 163679
Very hard to unset attributes.
Last modified: 2018-05-22 12:08:56 UTC
If I have an attribute list, it is easy to 1. Set character 4 to bold. 2. Set character 4 to non-bold. but it is very hard to 3. Set character 4 not to have a boldness attribute. In fact, without access to the internal list structure this feels like one would have to build a new list, then empty the original one, then copy over. (There are two versions of this problem: single attribute and all attributes.)\
Probably something like pango_attr_list_unset (list, start, end, type); would work. (Would split attributes as necessary, that makes the implementation not *entirely* trivial, since you have to move the second half of the attribute further away in the attribute list.) PangoAttrList was thought of originally as mostly a write-only data structure.. and app would have some other internal representation of attributes and would convert that representation to a PangoAttrList to pass it to Pango. A patch would be appreciated.
Created attachment 35912 [details] [review] Suggested patch This patch is based on existing public pango API (so I can still use it outside pango) and shouldn't be too slow for realistic attribute lists.
Patch looks good. Owen, what do you think?
Ok, we need a better patch that uses the internals of the attrlist.
Created attachment 66175 [details] [review] a patch for pango_attr_list_unset( ) I wrote a patch and implemented pango_attr_list_unset( ) with using the internals of the attrlist. :)
Thanks LingNing, but your patch doesn't split attributes if a non-perfect match happens. See Morten's patch for example
ok, let me see. :)
Created attachment 66411 [details] [review] modify the patch modify the pango_attr_list_unset( ). Then the patch can split attributes if a non-perfect match happens.
LingNing, can you attach a correctly indented patch, with documentation block please?
ok, I will attach it. :)
Created attachment 68764 [details] [review] modified patch I modified the indenting and added the documentation block.
-- 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/22.