GNOME Bugzilla – Bug 155948
Preserve normalization for backspace-deletes-character
Last modified: 2018-05-22 12:06:44 UTC
In the mythical lost original backspace-deletes-character patch for GtkTextView and GtkEntry, what I did was: normalized_text = g_utf8_normalize (cluster_text, -1, G_NORMALIZE_NFD); gboolean recompose = strcmp (normalized_text, cluster_text) != 0; len = g_utf8_strlen (cluster_text, -1); if (len > 1) { int bytelen = g_utf8_offset_to_pointer (normalized_text, len - 1) - normalized_text; char *to_insert; if (recompose) to_insert = g_utf8_normalize (cluster_text, bytelen, G_NORMALIZE_NFC); else to_insert = g_strndup (cluster_text, bytelen); /* insert text */ g_free (to_insert); } g_free (normalized_text); This avoids a bug where deleting one accent off a precomposed form with two accents will give a decomposed form.
> if (recompose) > to_insert = g_utf8_normalize (cluster_text, bytelen, G_NORMALIZE_NFC); > else > to_insert = g_strndup (cluster_text, bytelen); Did you mean 's/cluster_text/normalized_text/'?
Yes.
Created attachment 38640 [details] [review] Proposed patch So, please consider the proposed patch. However, I wonder how to test the case, i.e. which scripts fall in the category. Not Latin/Greek/Cyrillic, at least.
Owen, do you have a text snipplet to test this patch with ?
Here's one that should test out this code: U+9DF U+9BE (য়া) Hitting delete after that should turn it into U+9DF, not it's decomposition: U+9AF U+9BC
I'm going to add API to Pango to handle backspace deletions. I'll take care of this there and make Gtk+ use that.
-- 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/19.