[vte/vte-0-34] CJK: Fix width of Box Drawing and Block Elements characters



commit f2012351c2e609b9ae3152d7c43b3505bfac3ad1
Author: Christian Persch <chpe gnome org>
Date:   Sat Aug 25 21:32:41 2012 +0200

    CJK: Fix width of Box Drawing and Block Elements characters
    
    U+254C..U+254F and U+2574..U+257F have East Asian Width property
    N (neutral) while all the other line drawing characters are
    A (ambigous). This makes those characters not match up with those
    other line drawing characters from the Box Drawing (U+2500..U+257F)
    block when using VTE_CJK_WIDTH=wide; so we forcibly treat them as
    ambigous too.
    
    And we also do the same for the Terminal Graphic Characters
    (U+2596..U+259F) as well as U+2590 and U+2591 from the Block Elements
    (U+2580..U+259F) block.
    
    The reasons *why* these characters are N instead of A is not clear.
    It certainly looks like a bug in Unicode, but these characters are there
    since Unicode 1.1, and even the first version of UAX#11
    (DTR#11, http://www.unicode.org/reports/dtr11.html) has them as N.

 src/iso2022.c |   18 +++++++++++++++++-
 1 files changed, 17 insertions(+), 1 deletions(-)
---
diff --git a/src/iso2022.c b/src/iso2022.c
index 79a9e01..6856689 100644
--- a/src/iso2022.c
+++ b/src/iso2022.c
@@ -354,6 +354,22 @@ _vte_iso2022_ambiguous_width(struct _vte_iso2022_state *state)
 	return 1;
 }
 
+static gboolean
+_vte_unichar_iswide_cjk(gunichar c)
+{
+        /* U+254C..U+254F and U+2574..U+257F have East Asian Width property
+         * N (neutral) while all the other line drawing characters are
+         * A (ambigous). This makes those characters not match up with those
+         * other line drawing characters from the Box Drawing (U+2500..U+257F)
+         * block; so we treat them as ambigous too.
+         *
+         * And we also do the same for the Terminal Graphic Characters
+         * (U+2596..U+259F) as well as U+2590 and U+2591 from the Block Elements 
+         * (U+2580..U+259F) block.
+         */
+        return G_UNLIKELY(c >= 0x2500 && c <= 0x259f);
+}
+
 static inline gboolean
 _vte_iso2022_is_ambiguous(gunichar c)
 {
@@ -361,7 +377,7 @@ _vte_iso2022_is_ambiguous(gunichar c)
 		return FALSE;
 	if (G_UNLIKELY (g_unichar_iszerowidth (c)))
 		return FALSE;
-	return G_UNLIKELY (!g_unichar_iswide (c) && g_unichar_iswide_cjk (c));
+	return G_UNLIKELY (!g_unichar_iswide (c) && (g_unichar_iswide_cjk (c) || _vte_unichar_iswide_cjk (c)));
 }
 
 int



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]