You are not logged in.

#1 2024-05-03 03:37:16

cfr
Member
From: Cymru
Registered: 2011-11-27
Posts: 7,168

[solved] Query font availability: finding installed fonts for lang X?

According to fc-match's man page:

 fc-match sans:lang=en

should
> Display the best matching font categorized into sans-serif generic family, filtered by English language

This appears to work fine:

fc-match sans:lang-en
NotoSans-Regular.ttf: "Noto Sans" "Regular"

and, indeed, NotoSans-Regular.ttf can be used to typeset or display English.

Suppose instead I want to find a font to typeset or display Thai.

fc-match sans:lang-th
NotoSans-Regular.ttf: "Noto Sans" "Regular"

Huh. So NotoSans-Regular.ttf supports Thai and English?

otfinfo -s /usr/share/fonts/noto/NotoSans-Regular.ttf
DFLT            Default
cyrl            Cyrillic
cyrl.MKD        Cyrillic/Macedonian
cyrl.SRB        Cyrillic/Serbian
dev2            Devanagari v.2
grek            Greek
grek.APPH       Greek/Phonetic transcription—Americanist conventions
grek.IPPH       Greek/Phonetic transcription—IPA conventions
latn            Latin
latn.APPH       Latin/Phonetic transcription—Americanist conventions
latn.CAT        Latin/Catalan
latn.IPPH       Latin/Phonetic transcription—IPA conventions
latn.MAH        Latin/Marshallese
latn.MOL        Latin/Moldavian
latn.NAV        Latin/Navajo
latn.ROM        Latin/Romanian

I don't know much about Thai, but I'm pretty sure it doesn't use Latin, Cyrillic or Greek script. Devanagari seems most plausible, but https://en.wikipedia.org/wiki/Devanagari doesn't mention Thai.
Moreover, if I try to use this font to typeset Thai, TeX tells me it does not support Thai and I get nothing but empty boxes.

This is not surprising, because, as far as I can tell, support for Thai is included in a different font:

otfinfo -s /usr/share/fonts/noto/NotoSansThai-Regular.ttf
DFLT            Default
thai            Thai

And, indeed, selecting this font succeeds with most of the Thai characters in my document. (There are some missing codepoints, so it isn't a great font for Thai, but it is a reasonable match for fontconfig to return.)

So otfinfo doesn't suggest NotoSans-Regular.ttf for Thai, even though fontconfig does. What I can't figure out is *why* fc-match suggests NotoSans-Regular.ttf for Thai.

fc-match -v sans:lang-th
Pattern has 44 elts (size 48)
family: "Noto Sans"(w)
familylang: "en"(s)
style: "Regular"(s)
stylelang: "en"(s)
fullname: "Noto Sans Regular"(w)
fullnamelang: "en"(s)
slant: 0(i)(s)
weight: 80(f)(s)
width: 100(f)(s)
size: 12(f)(s)
pixelsize: 12.5(f)(s)
foundry: "GOOG"(s)
antialias: True(w)
hintstyle: 1(i)(w)
hinting: True(s)
verticallayout: False(s)
autohint: False(s)
globaladvance: True(s)
file: "/usr/share/fonts/noto/NotoSans-Regular.ttf"(s)
index: 0(i)(w)
outline: True(s)
scalable: True(s)
dpi: 75(f)(s)
rgba: 1(i)(w)
scale: 1(f)(s)
charset:
0000: 00000000 ffffffff ffffffff 7fffffff 00000000 ffffffff ffffffff ffffffff
0001: ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff
0002: ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff
0003: ffffffff ffffffff ffffffff fcffffff ffffd7f0 fffffffb ffffffff ffff0003
0004: ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff
0005: ffffffff 0000ffff 00000000 00000000 00000000 00000000 00000000 00000000
0010: 00000000 00000000 00000000 00000000 00000000 00000000 00000000 08000000
001a: 00000000 00000000 00000000 00000000 00000000 ffff0000 00007fa1 00000000
001c: 00000000 00000000 00000000 00000000 000001ff 00000000 00000000 00000000
001d: ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff fbffffff
001e: ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff
001f: 3f3fffff ffffffff aaff3f3f 3fffffff ffffffff ffdfffff efcfffdf 7fdcffff
0020: ffffffff ffffffff ffffffff fff3ffdf 1fff7fff ffffffff 00000001 00010000
0021: ffffffff ffffffff ffffffff 00000000 00000218 00000000 00000000 00000000
0022: 00040000 00000000 00000000 00000000 00000000 00000000 00000000 00000000
0025: 00000000 00000000 00000000 00000000 00000000 00000000 00001000 00000000
002c: 00000000 00000000 00000000 ffffffff 00000000 00000000 00000000 00000000
002d: 00000000 00000000 00000000 00000000 00000000 00000000 00000000 ffffffff
002e: ffffffff ffffffff 3fffffff 00000000 00000000 00000000 00000000 00000000
00a6: 00000000 00000000 ffffffff ffffffff ffffffff 00000000 00000000 00000000
00a7: ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff 03eb07ff fffc0000
00a9: 00000000 00004000 00000000 00000000 00000000 00000000 00000000 00000000
00ab: 00000000 ffff0000 ffffffff 00000fff 00000000 00000000 00000000 00000000
00fb: 0000007f 00000000 00000000 00000000 00000000 00000000 00000000 00000000
00fe: 00000001 0000ffff 00000000 00000000 00000000 00000000 00000000 80000000
00ff: 00000000 00000000 00000000 00000000 00000000 00000000 00000000 30000000
0107: 00000000 00000000 00000000 00000000 ffffffbf 07fdffff 00000000 00000000
01df: 7fffffff 00000000 00000000 00000000 00000000 00000000 00000000 00000000
(s)
lang: aa|ab|af|ast|av|ay|az-az|ba|bm|be|bg|bi|bin|br|bs|bua|ca|ce|ch|chm|co|cs|cu|cv|cy|da|de|el|en|eo|es|et|eu|fi|fj|fo|fr|ff|fur|fy|ga|gd|gl|gn|gv|ha|haw|ho|hr|hu|ia|ig|id|ie|ik|io|is|it|kaa|ki|kk|kl|ku-am|kum|kv|kw|ky|la|lb|lez|ln|lt|lv|mg|mh|mi|mk|mo|mt|nb|nds|nl|nn|no|nr|nso|ny|oc|om|os|pl|pt|rm|ro|ru|sah|sco|se|sel|sh|shs|sk|sl|sm|sma|smj|smn|sms|so|sq|sr|ss|st|sv|sw|tg|tk|tl|tn|to|tr|ts|tt|tw|tyv|uk|uz|ve|vi|vo|vot|wa|wen|wo|xh|yap|yo|zu|ak|an|ber-dz|crh|csb|ee|fat|fil|hsb|ht|hz|jv|kab|kj|kr|ku-tr|kwm|lg|li|mn-mn|ms|na|ng|nv|pap-an|pap-aw|qu|quz|rn|rw|sc|sg|sn|su|ty|za|agr|ayc|bem|dsb|lij|mfe|mhr|miq|mjw|nhn|niu|rif|sgs|szl|tpi|unm|wae|yuw(s)
fontversion: 131924(i)(s)
capability: "otlayout:DFLT otlayout:cyrl otlayout:dev2 otlayout:grek otlayout:latn"(w)
fontformat: "TrueType"(s)
embeddedbitmap: True(s)
decorative: False(s)
lcdfilter: 1(i)(w)
namelang: "cy"(s)
prgname: "fc-match"(s)
postscriptname: "NotoSans-Regular"(s)
color: False(s)
symbol: False(s)
variable: False(s)
fonthashint: True(s)
order: 0(i)(s)
desktop: "KDE"(s)
namedinstance: False(s)
fontwrapper: "SFNT"(s)

Nothing in this output suggests the font supports Thai, as far as I can tell. While the output is verbose, it doesn't obviously explain why fontconfig has returned the erroneous result.

I thought this might be a peculiarity of Noto, but it is not:

fc-match -v serif:lang-th
Pattern has 44 elts (size 48)
family: "Heuristica"(w) "Эвристика"(w)
familylang: "en"(s) "ru"(w)
style: "Regular"(s)
stylelang: "en"(s)
fullname: "Heuristica Regular"(w)
fullnamelang: "en"(s)
slant: 0(i)(s)
weight: 80(f)(s)
width: 100(f)(s)
size: 12(f)(s)
pixelsize: 12.5(f)(s)
foundry: "PfEd"(s)
antialias: True(w)
hintstyle: 1(i)(w)
hinting: True(s)
verticallayout: False(s)
autohint: False(s)
globaladvance: True(s)
file: "/usr/share/fonts/TTF/Heuristica-Regular.ttf"(s)
index: 0(i)(w)
outline: True(s)
scalable: True(s)
dpi: 75(f)(s)
rgba: 1(i)(w)
scale: 1(f)(s)
charset:
0000: 00000000 ffffffff ffffffff 7fffffff 00000000 ffffffff ffffffff ffffffff
0001: ffffffff 66333ff3 ff3ffdfe fff3ff3f 90d7c240 00858383 201fe000 f331c3cc
0002: cfffffff 008cc0c0 ffff0032 ffffffff ffffffff c7ffffff ffffddc0 000043ff
0003: f7e29fff 2f17fff9 30000040 00000002 00000000 090c0000 00000080 00000000
0004: ffffffff ffffffff ffffffff 003c0c0c ccff0000 fcffff3c ffff819f 03ffffff
0005: 000c0000 00000030 00000000 00000000 00000000 00000000 00000000 00000000
001d: 00000000 00000000 6dcfaff8 11000002 f8000000 7edffb7f 00000000 00000000
001e: cfffffff ffff3cff ffffffff f0ffff0f 0bffffff ffffffff ffffffff 03ffffff
0020: 771bffff 060dff47 80000010 83f1ffff 000003ff 20001000 00000000 00000000
0021: 80400000 0000000c ffff0000 00000000 00000000 00000000 00000000 00000000
0022: 00040000 00000000 00000000 00000000 00000000 00000000 00000000 00000000
002c: 00000000 00000000 00000000 00024000 00000000 00000000 00000000 00000000
00a7: 00000000 00000000 00000000 00000000 00002700 00000000 00000000 00000000
00e0: 43108110 c2a10000 c6022060 23c50841 0d04010e 0001fe00 00000000 00000000
00ef: 00000000 00000000 00000000 00000000 00000000 00000000 00000000 00a86000
00f1: 00000004 00000000 00000000 00000000 00000000 01800000 ffe00000 ffffffff
00f2: 0000c05f cf020348 00000dfe 00000000 00000000 00000000 00000000 00000000
00f6: 00000000 00000000 00001ff8 00000000 00000000 00000000 0013ce00 00700000
00f7: 00000000 00000000 00000000 07ffffff 00000000 00108000 00000000 ff7fffff
00fb: 0000001f 00000000 00000000 00000000 00000000 00000000 00000000 00000000
(s)
lang: aa|ast|av|ay|az-az|be|bg|bi|bin|br|bs|bua|ce|ch|chm|co|cs|cv|cy|da|de|en|eo|es|et|eu|fi|fj|fo|fr|fur|fy|ga|gd|gl|gn|gv|ho|hr|hu|ia|ig|id|ie|ik|io|is|it|kaa|ki|kk|kum|kv|kw|ky|la|lb|lez|ln|mg|mi|mk|mo|mt|nb|nds|nl|nn|no|nr|nso|ny|oc|om|os|pl|pt|rm|ro|ru|sah|sel|sk|sl|sma|smj|smn|so|sq|sr|ss|st|sv|sw|tg|tk|tl|tn|tr|ts|tt|tw|tyv|uk|uz|ve|vo|vot|wa|wen|wo|xh|yap|yo|zu|ak|an|ber-dz|crh|csb|ee|fat|fil|hsb|ht|hz|jv|kab|kj|ku-tr|kwm|lg|li|mn-mn|ms|na|ng|pap-an|pap-aw|qu|quz|rn|rw|sc|sg|sn|su|za|agr|ayc|bem|dsb|lij|mfe|mhr|miq|mjw|nhn|niu|rif|szl|tpi|unm|wae|yuw(s)
fontversion: 65536(i)(s)
capability: "otlayout:cyrl otlayout:grek otlayout:latn"(w)
fontformat: "TrueType"(s)
embeddedbitmap: True(s)
decorative: False(s)
lcdfilter: 1(i)(w)
namelang: "cy"(s)
prgname: "fc-match"(s)
postscriptname: "Heuristica-Regular"(s)
color: False(s)
symbol: False(s)
variable: False(s)
fonthashint: True(s)
order: 0(i)(s)
desktop: "KDE"(s)
namedinstance: False(s)
fontwrapper: "SFNT"(s)

So evidently fontconfig is misconfigured somewhere. /etc/fonts/conf.d/66-noto-sans.conf is just a symlink to /usr/share/fontconfig/conf.default/66-noto-sans.conf

<?xml version="1.0"?>
<!DOCTYPE fontconfig SYSTEM "fonts.dtd">
<fontconfig>
<alias>
<family>sans-serif</family>
<prefer>
<family>Noto Sans</family>
</prefer>
</alias>
</fontconfig>

This doesn't seem obviously problematic. I've no objection to fontconfig preferring Noto Sans for sans serif. I just don't want it suggesting NotoSans-Regular.ttf rather than NotoSansThai-Regular.ttf for Thai.

/usr/share/fontconfig/conf.default/66-noto-sans.conf is owned by noto-fonts 1:24.4.1-1

But I've never really understood fontconfig, so I'm not even sure if I'm looking in the right places.

Is there a problem here? If not, where should I be looking?

[I reread the wiki page on fontconfig. I also reread the comments on the discussion page. I found a disproportionate number authored by me.]

Last edited by cfr (2024-05-04 16:18:09)


CLI Paste | How To Ask Questions

Arch Linux | x86_64 | GPT | EFI boot | refind | stub loader | systemd | LVM2 on LUKS
Lenovo x270 | Intel(R) Core(TM) i5-7200U CPU @ 2.50GHz | Intel Wireless 8265/8275 | US keyboard w/ Euro | 512G NVMe INTEL SSDPEKKF512G7L

Offline

#2 2024-05-03 06:53:27

seth
Member
From: Don't DM me only for attention
Registered: 2012-09-03
Posts: 73,883

Re: [solved] Query font availability: finding installed fonts for lang X?

https://wiki.archlinux.org/title/Font_c … ault_fonts - apparently noto doesn't ship with a resp. config for various languages?

Offline

#3 2024-05-03 19:34:03

cfr
Member
From: Cymru
Registered: 2011-11-27
Posts: 7,168

Re: [solved] Query font availability: finding installed fonts for lang X?

seth wrote:

https://wiki.archlinux.org/title/Font_c … ault_fonts - apparently noto doesn't ship with a resp. config for various languages?

But shouldn't fontconfig determine that the 'preferred' font doesn't satisfy the search criteria and find a match which does? Or the default config for Noto say 'prefer Noto Sans if appropriate' or something?

Does fontconfig make any use of the information provided by fonts? I guess I assumed it made some use of it, but if not .... How can I read man and wiki pages for something and miss something that basic?


CLI Paste | How To Ask Questions

Arch Linux | x86_64 | GPT | EFI boot | refind | stub loader | systemd | LVM2 on LUKS
Lenovo x270 | Intel(R) Core(TM) i5-7200U CPU @ 2.50GHz | Intel Wireless 8265/8275 | US keyboard w/ Euro | 512G NVMe INTEL SSDPEKKF512G7L

Offline

#4 2024-05-03 19:56:15

seth
Member
From: Don't DM me only for attention
Registered: 2012-09-03
Posts: 73,883

Re: [solved] Query font availability: finding installed fonts for lang X?

Sure, "should" … - probably does.

fc-match sans:lang-th

try

fc-match sans:lang=th

Offline

#5 2024-05-04 16:17:19

cfr
Member
From: Cymru
Registered: 2011-11-27
Posts: 7,168

Re: [solved] Query font availability: finding installed fonts for lang X?

seth wrote:
fc-match sans:lang=th

I'm really sorry for wasting your time. Thank-you.


CLI Paste | How To Ask Questions

Arch Linux | x86_64 | GPT | EFI boot | refind | stub loader | systemd | LVM2 on LUKS
Lenovo x270 | Intel(R) Core(TM) i5-7200U CPU @ 2.50GHz | Intel Wireless 8265/8275 | US keyboard w/ Euro | 512G NVMe INTEL SSDPEKKF512G7L

Offline

Board footer

Powered by FluxBB