summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJean Abou Samra <jean@abou-samra.fr>2022-12-08 13:02:19 +0100
committerJean Abou Samra <jean@abou-samra.fr>2022-12-14 15:27:34 +0100
commit6e3fe92b20edb1d91683efa9aea68d35a887a83c (patch)
treee1cac63e6e324758806c91e588c88adbb09e4ee8
parent8b854dddb0723e1c0ba53c5f2b29771db4f4265d (diff)
downloadfontconfig-6e3fe92b20edb1d91683efa9aea68d35a887a83c.tar.gz
Ignore LC_CTYPE if set to "UTF-8"
LC_CTYPE is set to "UTF-8" on some macOS systems, which is POSIX-compliant in a strict sense, but breaks the usual assumption that a locale name has the form "ll_LL.encoding". https://unix.stackexchange.com/questions/503110/valid-values-for-lc-ctype Previously, this would cause the warning Fontconfig warning: ignoring UTF-8: not a valid region tag Now, we just skip this variable if set to "UTF-8", since that value doesn't give any language information, and move on to try LANG.
-rw-r--r--src/fcdefault.c12
1 files changed, 11 insertions, 1 deletions
diff --git a/src/fcdefault.c b/src/fcdefault.c
index 6995216..d00c494 100644
--- a/src/fcdefault.c
+++ b/src/fcdefault.c
@@ -62,7 +62,17 @@ retry:
if (!langs || !langs[0])
langs = getenv ("LC_ALL");
if (!langs || !langs[0])
- langs = getenv ("LC_CTYPE");
+ {
+ langs = getenv ("LC_CTYPE");
+ // On some macOS systems, LC_CTYPE is set to "UTF-8", which doesn't
+ // give any languge information. In this case, ignore LC_CTYPE and
+ // continue the search with LANG.
+ if (langs && (FcStrCmpIgnoreCase((const FcChar8 *) langs,
+ (const FcChar8 *)"UTF-8") == 0))
+ {
+ langs = NULL;
+ }
+ }
if (!langs || !langs[0])
langs = getenv ("LANG");
if (langs && langs[0])