Can't find monospace font for thai on Linux (was: Somehow a specific plaintext file or its view-source equivalent aren't monospace)
Categories
(Core :: Layout: Text and Fonts, defect)
Tracking
()
People
(Reporter: emilio, Unassigned)
References
()
Details
Going to https://www.nat.go.th/jquery.min.map shows non-monospace text for me and James Graham at least (on Linux).
This repros on a clean profile and I can't make any sense of it (this is without any font fingerprinting protection stuff or what not, plus other plaintext files work fine).
Changing font-family on the inspector doesn't change anything (other than the size due to the monospace quirk). Even sans-serif or something doesn't change the font... But other properties do work (??)
| Reporter | ||
Comment 1•1 year ago
|
||
Err, of course forgot to paste the last bit:
Jonathan do you have any idea off the top of your head about what might be going on?
| Reporter | ||
Comment 2•1 year ago
|
||
I was thinking that maybe content-language or something could affect it but it doesn't seem to be specified according to devtools.
| Reporter | ||
Comment 3•1 year ago
|
||
So the plaintext file has ~never been monospace (tried far back to FF 40 or so).
But the view-source used to be monospace until some change around here: https://hg.mozilla.org/mozilla-central/pushloghtml?fromchange=0f6958f498427fad830cdf94e279d8acd16402c9&tochange=f09f24f2b545919ab0db4bd352c276779c58bcc6
| Reporter | ||
Comment 4•1 year ago
|
||
Bug 1551276 somehow is the only loosely related thing, I believe?
| Reporter | ||
Comment 5•1 year ago
|
||
So document.characterSet is windows-874 for us and windows-1252 for Chrome. I don't think that's necessarily the culprit but is that problematic somehow Henri?
| Reporter | ||
Comment 6•1 year ago
|
||
Ok, so that does explain... when the charset changes, RecomputeLanguageFromCharset() says th, and I guess we don't have any monospace fonts on Linux for th somehow? Seems we should still fallback to something monospace tho :)
So, reduced test-case:
data:text/html,<html lang="th"><pre>Am I monospace</pre>
| Reporter | ||
Updated•1 year ago
|
Comment 7•1 year ago
|
||
Yeah, if we decide the content language is th, then we'll use the generic font pref settings for Thai, and probably fontconfig doesn't find a monospaced Thai font.
Given that the content of the file is (largely, if not entirely?) Latin-script text, it would be preferable for us to use the Latin font prefs, regardless of what we think the content language is. The changes planned for bug 1748636 should make that work.
Comment 8•1 year ago
|
||
(In reply to Emilio Cobos Álvarez (:emilio) from comment #5)
So document.characterSet is windows-874 for us and windows-1252 for Chrome. I don't think that's necessarily the culprit but is that problematic somehow Henri?
I didn't actually debug this, but I'm pretty sure that what's happening here is:
- Autodetection happens, because this is text/plain without an encoding label.
- The content doesn't have enough non-ASCII (superficially looks 100% ASCII) for detection from content to work, so the encoding comes from the .th TLD, which maps to windows-874.
Comment 9•1 year ago
|
||
The severity field is not set for this bug.
:jfkthame, could you have a look please?
For more information, please visit BugBot documentation.
Comment 10•1 year ago
|
||
Ok, so that does explain... when the charset changes,
RecomputeLanguageFromCharset()saysth, and I guess we don't have any monospace fonts on Linux forthsomehow? Seems we should still fallback to something monospace tho :)So, reduced test-case:
data:text/html,<html lang="th"><pre>Am I monospace</pre>
For me (on Ubuntu), this (and the original example) does render with monospace (Noto Mono, to be exact). Presumably your fontconfig setup is somewhat different, and that leads to the differing behavior.
Out of curiosity, what does LANG=th fc-match -a monospace | head list for you? And what font is actually being used for the content? (I get Noto Sans Thai as the top match, followed by Noto Mono and other monospaced fonts.)
Comment 11•1 year ago
|
||
(Marking this as S4, given that it seems fairly edge-casey, depending on local fontconfig setup. Hopefully future font-prefs redesign will help here, anyhow.)
| Reporter | ||
Comment 12•1 year ago
|
||
(In reply to Jonathan Kew [:jfkthame] from comment #10)
Out of curiosity, what does
LANG=th fc-match -a monospace | headlist for you? And what font is actually being used for the content? (I get Noto Sans Thai as the top match, followed by Noto Mono and other monospaced fonts.)
$ LANG=th fc-match -a monospace
FreeSerif.otf: "FreeSerif" "ปกติ"
NotoSansMono-Regular.ttf: "Noto Sans Mono" "Regular"
NotoSansMono-Medium.ttf: "Noto Sans Mono" "Medium"
NotoSansMono-Light.ttf: "Noto Sans Mono" "Light"
NotoSansMono-Thin.ttf: "Noto Sans Mono" "Thin"
NotoSansMono-Bold.ttf: "Noto Sans Mono" "Bold"
NotoSansMono-Black.ttf: "Noto Sans Mono" "Black"
NimbusMonoPS-Regular.otf: "Nimbus Mono PS" "Regular"
NimbusMonoPS-Bold.otf: "Nimbus Mono PS" "Bold"
NimbusMonoPS-Italic.otf: "Nimbus Mono PS" "Italic"
NimbusMonoPS-BoldItalic.otf: "Nimbus Mono PS" "Bold Italic"
FreeMono.otf: "FreeMono" "Regular"
FreeMonoBold.otf: "FreeMono" "Bold"
...
And what font is actually being used for the content?
Free Serif.
I guess Free Serif gets chosen because it has th explicitly on its styles and so on:
Pattern has 44 elts (size 48)
family: "FreeSerif"(w)
familylang: "en"(s)
style: "ปกติ"(w) "Regular"(w) "нормален"(w) "normal"(w) "obyčejné"(w) "Mittel"(w) "µεσαία"(w) "Normaali"(w) "Normál"(w) "Normale"(w) "Gemiddeld"(w) "odmiana zwykła"(w) "Обычный"(w) "Normálne"(w) "menengah"(w) "прямій"(w) "Navadno"(w) "vidējs"(w) "normalusis"(w) "عادی"(w) "vừa"(w) "Arrunta"(w) "सामान्य"(w)
stylelang: "th"(s) "en"(w) "bg"(w) "ca"(w) "cs"(w) "de"(w) "el"(w) "fi"(w) "hu"(w) "it"(w) "nl"(w) "pl"(w) "ru"(w) "sk"(w) "id"(w) "uk"(w) "sl"(w) "lv"(w) "lt"(w) "fa"(w) "vi"(w) "eu"(w) "hi"(w)
fullname: "FreeSerif"(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: "GNU "(w)
antialias: True(w)
hintstyle: 1(i)(w)
hinting: True(w)
verticallayout: False(s)
autohint: False(s)
globaladvance: True(s)
file: "/usr/share/fonts/gnu-free/FreeSerif.otf"(w)
index: 0(i)(w)
outline: True(w)
scalable: True(w)
dpi: 75(f)(s)
rgba: 1(i)(w)
scale: 1(f)(s)
charset: [ommitted]
(w)
lang: aa|ab|af|am|ar|as|ast|av|ay|az-az|az-ir|ba|bm|be|bg|bh|bho|bi|bin|bn|br|bs|bua|ca|ce|ch|chm|chr|co|cs|cu|cv|cy|da|de|el|en|eo|es|et|eu|fa|fi|fj|fo|fr|ff|fur|fy|ga|gd|gez|gl|gn|gu|gv|ha|haw|he|hi|ho|hr|hu|hy|ia|ig|id|ie|ik|io|is|it|ka|kaa|ki|kk|kl|kok|ks|ku-am|ku-ir|kum|kv|kw|ky|la|lb|lez|ln|lt|lv|mg|mh|mi|mk|ml|mo|mr|mt|nb|nds|ne|nl|nn|no|nr|nso|ny|oc|om|or|os|pa|pl|ps-af|ps-pk|pt|rm|ro|ru|sa|sah|sco|se|sel|sh|shs|si|sk|sl|sm|sma|smj|smn|sms|so|sq|sr|ss|st|sv|sw|ta|tg|th|ti-er|ti-et|tig|tk|tl|tn|to|tr|ts|tt|tw|tyv|ug|uk|ur|uz|ve|vi|vo|vot|wa|wen|wo|xh|yap|yi|yo|zu|ak|an|ber-dz|byn|crh|csb|dv|ee|fat|fil|hne|hsb|ht|hz|jv|kab|kj|kr|ku-iq|ku-tr|kwm|lg|li|mai|mn-mn|ms|na|ng|nv|ota|pa-pk|pap-an|pap-aw|qu|quz|rn|rw|sc|sd|sg|sid|sn|su|ty|wal|za|lah|brx|sat|doi|mni|und-zmth|anp|bhb|hif|mag|raj|the|agr|ayc|bem|ckb|dsb|lij|mfe|mhr|miq|mjw|nhn|niu|rif|sgs|szl|tpi|unm|wae|yuw|got(s)
fontversion: 27015662(i)(s)
capability: "otlayout:DFLT otlayout:arab otlayout:armn otlayout:beng otlayout:bng2 otlayout:bugi otlayout:copt otlayout:cyrl otlayout:dev2 otlayout:deva otlayout:gjr2 otlayout:glag otlayout:goth otlayout:grek otlayout:gujr otlayout:gur2 otlayout:guru otlayout:hano otlayout:hebr otlayout:latn otlayout:mlm2 otlayout:mlym otlayout:musc otlayout:ory2 otlayout:orya otlayout:sinh otlayout:taml otlayout:thai otlayout:tml2"(w)
fontformat: "CFF"(w)
embeddedbitmap: True(s)
decorative: False(s)
lcdfilter: 1(i)(w)
namelang: "th"(s)
prgname: "fc-match"(s)
postscriptname: "FreeSerif"(w)
color: False(w)
symbol: False(s)
variable: False(s)
fonthashint: False(w)
order: 0(i)(s)
desktop: "KDE"(s)
namedinstance: False(w)
fontwrapper: "SFNT"(w)
Comment 13•1 year ago
|
||
(In reply to Emilio Cobos Álvarez (:emilio) from comment #12)
I guess Free Serif gets chosen because it has
thexplicitly on its styles and so on:
Yeah, given that it explicitly claims Thai support:
lang: aa|ab|af|am|ar|as|ast|av|ay|az-az|az-ir|ba|bm|be|bg|bh|bho|bi|bin|bn|br|bs|bua|ca|ce|ch|chm|chr|co|cs|cu|cv|cy|da|de|el|en|eo|es|et|eu|fa|fi|fj|fo|fr|ff|fur|fy|ga|gd|gez|gl|gn|gu|gv|ha|haw|he|hi|ho|hr|hu|hy|ia|ig|id|ie|ik|io|is|it|ka|kaa|ki|kk|kl|kok|ks|ku-am|ku-ir|kum|kv|kw|ky|la|lb|lez|ln|lt|lv|mg|mh|mi|mk|ml|mo|mr|mt|nb|nds|ne|nl|nn|no|nr|nso|ny|oc|om|or|os|pa|pl|ps-af|ps-pk|pt|rm|ro|ru|sa|sah|sco|se|sel|sh|shs|si|sk|sl|sm|sma|smj|smn|sms|so|sq|sr|ss|st|sv|sw|ta|tg|th|ti-er|ti-et|tig|tk|tl|tn|to|tr|ts|tt|tw|tyv|ug|uk|ur|uz|ve|vi|vo|vot|wa|wen|wo|xh|yap|yi|yo|zu|ak|an|ber-dz|byn|crh|csb|dv|ee|fat|fil|hne|hsb|ht|hz|jv|kab|kj|kr|ku-iq|ku-tr|kwm|lg|li|mai|mn-mn|ms|na|ng|nv|ota|pa-pk|pap-an|pap-aw|qu|quz|rn|rw|sc|sd|sg|sid|sn|su|ty|wal|za|lah|brx|sat|doi|mni|und-zmth|anp|bhb|hif|mag|raj|the|agr|ayc|bem|ckb|dsb|lij|mfe|mhr|miq|mjw|nhn|niu|rif|sgs|szl|tpi|unm|wae|yuw|got(s)
(and yes, it does include Thai chars), it makes sense that fontconfig will return it as the best match when given lang=th in the request. And sadly, that font includes (non-monospaced) Latin chars, so that's what you see.
For me, I get Noto Thai as the first match, but it does not include Latin letters, it's Thai-only. So it doesn't get in the way of the Latin chars falling back to the next match in the list, which is a suitably-monospaced font.
Description
•