From cba71eea549a65aa229559206f9204665510d0aa Mon Sep 17 00:00:00 2001 From: Matthias Clasen Date: Fri, 9 Jul 2021 12:10:37 -0400 Subject: Add a few missing chars to pango_is_zero_width The documentation for this function states that all bidi control chars are zero width, but it was missing the Isolate ones. Add them. Updated tests included. --- pango/pango-utils.c | 16 +++++++++++----- tests/testmisc.c | 11 +++++++++++ 2 files changed, 22 insertions(+), 5 deletions(-) diff --git a/pango/pango-utils.c b/pango/pango-utils.c index c90b4c86..894935e7 100644 --- a/pango/pango-utils.c +++ b/pango/pango-utils.c @@ -920,23 +920,29 @@ pango_is_zero_width (gunichar ch) * * 2028 LINE SEPARATOR * + * 2060 WORD JOINER + * 2061 FUNCTION APPLICATION + * 2062 INVISIBLE TIMES + * 2063 INVISIBLE SEPARATOR + * + * 2066 LEFT-TO-RIGHT ISOLATE + * 2067 RIGHT-TO-LEFT ISOLATE + * 2068 FIRST STRONG ISOLATE + * 2069 POP DIRECTIONAL ISOLATE + * * 202A LEFT-TO-RIGHT EMBEDDING * 202B RIGHT-TO-LEFT EMBEDDING * 202C POP DIRECTIONAL FORMATTING * 202D LEFT-TO-RIGHT OVERRIDE * 202E RIGHT-TO-LEFT OVERRIDE * - * 2060 WORD JOINER - * 2061 FUNCTION APPLICATION - * 2062 INVISIBLE TIMES - * 2063 INVISIBLE SEPARATOR - * * FEFF ZERO WIDTH NO-BREAK SPACE */ return ((ch & ~(gunichar)0x007F) == 0x2000 && ( (ch >= 0x200B && ch <= 0x200F) || (ch >= 0x202A && ch <= 0x202E) || (ch >= 0x2060 && ch <= 0x2063) || + (ch >= 0x2066 && ch <= 0x2069) || (ch == 0x2028) )) || G_UNLIKELY (ch == 0x00AD || ch == 0x034F diff --git a/tests/testmisc.c b/tests/testmisc.c index c0f8c426..fe2e9075 100644 --- a/tests/testmisc.c +++ b/tests/testmisc.c @@ -178,6 +178,17 @@ test_is_zero_width (void) g_assert_true (pango_is_zero_width (0x034f)); g_assert_false (pango_is_zero_width ('a')); g_assert_false (pango_is_zero_width ('c')); + + g_assert_true (pango_is_zero_width (0x2066)); + g_assert_true (pango_is_zero_width (0x2067)); + g_assert_true (pango_is_zero_width (0x2068)); + g_assert_true (pango_is_zero_width (0x2069)); + + g_assert_true (pango_is_zero_width (0x202a)); + g_assert_true (pango_is_zero_width (0x202b)); + g_assert_true (pango_is_zero_width (0x202c)); + g_assert_true (pango_is_zero_width (0x202d)); + g_assert_true (pango_is_zero_width (0x202e)); } static void -- cgit v1.2.1