diff --git a/tools/tools/locale/etc/final-maps/widths.txt b/tools/tools/locale/etc/final-maps/widths.txt --- a/tools/tools/locale/etc/final-maps/widths.txt +++ b/tools/tools/locale/etc/final-maps/widths.txt @@ -858,7 +858,167 @@ 2 2 2 - 2 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + 0 0 0 0 @@ -2037,7 +2197,7 @@ 2 2 2 - 2 + 0 2 2 2 @@ -43510,6 +43670,7 @@ 2 2 2 + 0 2 2 2 diff --git a/tools/tools/locale/tools/getwidths.c b/tools/tools/locale/tools/getwidths.c --- a/tools/tools/locale/tools/getwidths.c +++ b/tools/tools/locale/tools/getwidths.c @@ -28,6 +28,39 @@ #include +#define SOFT_HYPHEN 0x00AD + +static int +width_override(int32_t wc) +{ + const utf8proc_property_t *wcprop; + + switch (wc) { + case SOFT_HYPHEN: + /* + * SOFT-HYPHEN is ignorable, but traditionally one column + * wide. + */ + return (1); + case 0x1160 ... 0x11ff: + /* + * Hangul Jamo medial vowels and final consonants are more of + * a combining character, and should be considered zero-width. + */ + return (0); + default: + break; + } + + /* Ignorable characters are typically zero-width. */ + wcprop = utf8proc_get_property(wc); + if (wcprop->ignorable) + return (0); + + /* No override by default, trust utf8proc's width. */ + return (-1); +} + int main(void) { @@ -43,9 +76,12 @@ wcc = utf8proc_category(wc); if (wcc == UTF8PROC_CATEGORY_CC) continue; - wcw = utf8proc_charwidth(wc); + wcw = width_override(wc); + if (wcw == -1) + wcw = utf8proc_charwidth(wc); if (wcw == 1) continue; + printf("%04X %d\n", wc, wcw); }