From 58f40ca402affaa4c49f04ab05409b18ef1bb8bf Mon Sep 17 00:00:00 2001 From: Hans Petter Jansson Date: Tue, 31 Jan 2023 01:53:57 +0100 Subject: [PATCH] symbols: Don't tag symbols from private use areas as ambiguous The presence of PUA glyphs is likely deliberate; the user knows what they're doing. Unfortunately we don't have a way to determine if imported glyphs in these ranges are wide or narrow. We default to narrow. This is an additional fix for #124 (GitHub). --- chafa/internal/chafa-symbols.c | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/chafa/internal/chafa-symbols.c b/chafa/internal/chafa-symbols.c index 1f9478cc..a658fd5b 100644 --- a/chafa/internal/chafa-symbols.c +++ b/chafa/internal/chafa-symbols.c @@ -356,6 +356,14 @@ generate_sextant_syms (ChafaSymbol *syms, gint first_ofs) return i; } +static gboolean +is_private_use (gunichar c) +{ + return !!((c >= 0xe000 && c <= 0xf8ff) + || (c >= 0xf0000 && c <= 0xfffff) + || (c >= 0x100000 && c <= 0x10ffff)); +} + static ChafaSymbolTags get_default_tags_for_char (gunichar c) { @@ -363,7 +371,8 @@ get_default_tags_for_char (gunichar c) if (g_unichar_iswide (c)) tags |= CHAFA_SYMBOL_TAG_WIDE; - else if (g_unichar_iswide_cjk (c)) + else if (g_unichar_iswide_cjk (c) + && !is_private_use (c)) tags |= CHAFA_SYMBOL_TAG_AMBIGUOUS; if (g_unichar_ismark (c)