From 6259d59b4d82b0e8b7705759e04262130a3426c8 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Daniel=20Ekl=C3=B6f?= Date: Fri, 16 Dec 2022 16:56:43 +0100 Subject: [PATCH] config: change default grapheme-width-method from wcswidth to double-width MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit The old default, wcswidth, simply calls wcswidth() on the grapheme cluster. This was supposedly the implementation with the highest application compatibility. Except we never even tried to measure it. It was just assumed. A lot of modern applications have better implementations. Let’s try to push support for better emoji support by changing our default method from wcswith to double-width. While far from correct (it’s not based on the Unicode tables), the ‘double-width’ method produces accurate results anyway. double-width is like wcswidth(), in that it adds together the individual wcwidths of all codepoints in the grapheme cluster. But, it limits the maximum width to 2. --- CHANGELOG.md | 1 + config.c | 2 +- doc/foot.ini.5.scd | 2 +- 3 files changed, 3 insertions(+), 2 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 9538ccca..4aadd7bc 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -75,6 +75,7 @@ * Set `PWD` environment variable in the slave process ([#1179][1179]). * DPI is now forced to 96 when found to be unreasonably high. * Set default log level to warning ([#1215][1215]). +* Default `grapheme-width-method` from `wcswidth` to `double-width`. [1166]: https://codeberg.org/dnkl/foot/issues/1166 [1179]: https://codeberg.org/dnkl/foot/issues/1179 diff --git a/config.c b/config.c index 7d849d5c..ea8d062f 100644 --- a/config.c +++ b/config.c @@ -3003,7 +3003,7 @@ config_load(struct config *conf, const char *conf_path, #if defined(FOOT_GRAPHEME_CLUSTERING) && FOOT_GRAPHEME_CLUSTERING .grapheme_shaping = fcft_caps & FCFT_CAPABILITY_GRAPHEME_SHAPING, #endif - .grapheme_width_method = GRAPHEME_WIDTH_WCSWIDTH, + .grapheme_width_method = GRAPHEME_WIDTH_DOUBLE, .delayed_render_lower_ns = 500000, /* 0.5ms */ .delayed_render_upper_ns = 16666666 / 2, /* half a frame period (60Hz) */ .max_shm_pool_size = 512 * 1024 * 1024, diff --git a/doc/foot.ini.5.scd b/doc/foot.ini.5.scd index 6443d2ba..6cdb7db8 100644 --- a/doc/foot.ini.5.scd +++ b/doc/foot.ini.5.scd @@ -1256,7 +1256,7 @@ any of these options. *max* uses the width of the largest codepoint in the cluster. - Default: _wcswidth_ + Default: _double-width_ *font-monospace-warn* Boolean. When enabled, foot will use heuristics to try to verify