FS#64083 - [noto-fonts] default/generic families are set too late, monospace/serif use sans-serif fallbacks

Attached to Project: Arch Linux
Opened by Brennan Kinney (polarathene) - Thursday, 10 October 2019, 03:08 GMT
Last edited by Antonio Rojas (arojas) - Tuesday, 10 December 2019, 18:17 GMT
Task Type Bug Report
Category Packages: Extra
Status Closed
Assigned To Antonio Rojas (arojas)
Architecture All
Severity Low
Priority Normal
Reported Version
Due in Version Undecided
Due Date Undecided
Percent Complete 100%
Votes 0
Private No

Details

Description:

The 66-*.conf fontconfig files for packaged noto fonts have been assigned `66` why?
Is it because of the categories described here?: http://www.linuxfromscratch.org/blfs/view/svn/x/tuning-fontconfig.html

> 40-49 map family to generic type
> 60-69 generic aliases, map generic to family

A problem I've noticed is that generic family type is handled earlier on with `49-sansserif.conf`, this assigns `sans-serif` if the current family list has no generic specified. This is usually handled in `45-generic.conf` and `45-latin.conf` for example, with alias->default blocks. The `default` syntax will use the same match->edit syntax as `mode="append_last"` according the the fontconfig docs, so if the font family name is specified when matching, it will regardless of marker position append the generic family to the end of the family list being generated. As the fontconfigs are iterated through, you end up with sans-serif for example being appended to the list multiple times(as well as other font families).

60-69 configs are appropriate for alias->prefer which prepends the preferred list of fonts to the target family in the list(first occurrence of the target family). `60-generic.conf` and `60-latin.conf` demonstrate this well. `69-urw-gothic.conf` not so much with its "Generic name assignment" assigning a default for `sans-serif` this far in, technically if the earlier fonts in the generated list were from a different generic family like `monospace` or `serif`, it's ok to ensure that you'll get a `sans-serif` family fallback in the list, but from what I understand, this is only useful for targeting by font-configs, it doesn't magically improve the list, so it's already missed any fonts that would be prepended/preferred to the family back in those two mentioned 60-*.conf files.

`69-urw-gothic.conf` does use alias-default again for a related font family name, the config perhaps intended to prepend it so that URW Gothic was the next in line/fallback,

- sans-serif, someOtherFontFamily(prior base list before reaching this config for example)
- URW Gothic(prepend by alias->prefer), sans-serif, someOtherFontFamily
- URW Gothic, sans-serif, someOtherFontFamily, sans-serif(appendLast by alias->default)
- URW Gothic, sans-serif, someOtherFontFamily, sans-serif, ITC Avant Garde Gothic(appendLast by alias->default)
- URW Gothic, sans-serif, someOtherFontFamily, sans-serif, ITC Avant Garde Gothic, URW Gothic(append by alias->accept)

"TeX Gyre Adventor" alias->accept rule(performs an "append" instead of "append_last") is not triggered unless specifically requested or some other config had added it earlier to append URW Gothic after it as fallback. All of the above is if sans-serif exists(which it will unless serif/monospace was set early on), if we ignore earlier font list, and specifically requested URW Gothic, we get:

> URW Gothic, sans-serif, ITC Avant Garde Gothic, URW Gothic

Or, if ITC Avant Garde Gothic was requested:

> ITC Avant Garde Gothic, URW Gothic, URW Gothic, sans-serif (assuming default sans-serif was added earlier)
> ITC Avant Garde Gothic, URW Gothic (if sans-serif was not added)

Actual query gets hits on 30-metric-aliases.conf, 69-urw-fallback-generics.conf, 69-urw-fallback-specifics.conf as well, ends up with the following list (`...` indicates multiple other fonts that I've omitted for brevity):

> FC_DEBUG=4 fc-match "ITC Avant Garde Gothic"
> "ITC Avant Garde Gothic"(s) "URW Gothic"(s) "URW Gothic L"(s) "TeX Gyre Adventor"(s) "URW Gothic"(s) ... "URW Gothic"(w) ... "sans-serif"(w) ... "sans-serif"(w) ... "ITC Avant Garde Gothic"(w) "sans-serif"(w) "ITC Avant Garde Gothic"(w) "sans-serif"(w) "sans-serif"(w) ... "sans-serif"(w)

Hopefully that gives a good example of the affect of fontconfig configs, in case there wasn't a clear understanding of how the rules work.

---

Back to the actual issue, it's not uncommon for monospace fonts not handled earlier to get sans-serif as a result. `49-sansserif.conf` will run before user config does(`50-user.conf`). A popular cited blog article on the topic(https://eev.ee/blog/2015/05/20/i-stared-into-the-fontconfig-and-the-fontconfig-stared-back-at-me/) shares that you can add the generic family, then do a match to remove `sans-serif` from such fonts. Doing so will then have the font list generated add "Noto Sans Mono", instead of "Noto Sans" as fallbacks.

You can do the same for fonts like "Noto Sans Mono", it just makes the default rules in the `66-noto-mono.conf` pointless. Perhaps a `46-defaults-noto.conf`(or whatever 2nd digit seems suitable) would be appropriate? The `66-noto-*.conf` files seem fine for alias->prefer.

---

Steps to reproduce:

1. Run `FC_DEBUG=4 fc-match "Noto Sans Mono" | grep -A2 "done"`
2. Notice sans-serif fonts in results instead of monospace fonts(results may be a little different depending on fontconfig differences):

family: "Noto Sans Mono"(s) "Bitstream Vera Sans"(w) "Verdana"(w) "Arial"(w) "Albany AMT"(w) "Luxi Sans"(w) "Nimbus Sans L"(w) "Nimbus Sans"(w) "Nimbus Sans"(w) "Helvetica"(w) "Nimbus Sans"(w) "Nimbus Sans L"(w) "Lucida Sans Unicode"(w) "BPG Glaho International"(w) "Tahoma"(w) "Nachlieli"(w) "Lucida Sans Unicode"(w) "Yudit Unicode"(w) "Kerkis"(w) "ArmNet Helvetica"(w) "Artsounk"(w) "BPG UTF8 M"(w) "Waree"(w) "Loma"(w) "Garuda"(w) "Umpush"(w) "Saysettha Unicode"(w) "JG Lao Old Arial"(w) "GF Zemen Unicode"(w) "Pigiarniq"(w) "B Davat"(w) "B Compset"(w) "Kacst-Qr"(w) "Urdu Nastaliq Unicode"(w) "Raghindi"(w) "Mukti Narrow"(w) "malayalam"(w) "Sampige"(w) "padmaa"(w) "Hapax Berbère"(w) "MS Gothic"(w) "UmePlus P Gothic"(w) "Microsoft YaHei"(w) "Microsoft JhengHei"(w) "WenQuanYi Zen Hei"(w) "WenQuanYi Bitmap Song"(w) "AR PL ShanHeiSun Uni"(w) "AR PL New Sung"(w) "MgOpen Modata"(w) "VL Gothic"(w) "IPAMonaGothic"(w) "IPAGothic"(w) "Sazanami Gothic"(w) "Kochi Gothic"(w) "AR PL KaitiM GB"(w) "AR PL KaitiM Big5"(w) "AR PL ShanHeiSun Uni"(w) "AR PL SungtiL GB"(w) "AR PL Mingti2L Big5"(w) "MS ゴシック"(w) "ZYSong18030"(w) "TSCu_Paranar"(w) "NanumGothic"(w) "UnDotum"(w) "Baekmuk Dotum"(w) "Baekmuk Gulim"(w) "KacstQura"(w) "Lohit Bengali"(w) "Lohit Gujarati"(w) "Lohit Hindi"(w) "Lohit Marathi"(w) "Lohit Maithili"(w) "Lohit Kashmiri"(w) "Lohit Konkani"(w) "Lohit Nepali"(w) "Lohit Sindhi"(w) "Lohit Punjabi"(w) "Lohit Tamil"(w) "Meera"(w) "Lohit Malayalam"(w) "Lohit Kannada"(w) "Lohit Telugu"(w) "Lohit Oriya"(w) "LKLUG"(w) "Noto Sans"(w) "FreeSans"(w) "Arial Unicode MS"(w) "Arial Unicode"(w) "Code2000"(w) "Code2001"(w) "URW Gothic"(w) "Nimbus Sans"(w) "Nimbus Sans Narrow"(w) "Droid Sans"(w) "sans-serif"(w) "Roya"(w) "Koodak"(w) "Terafik"(w) "FreeMono"(w) "Nimbus Mono PS"(w) "Droid Sans Mono"(w) "monospace"(w) "sans-serif"(w) "Helvetica"(w) "sans-serif"(w) "ITC Avant Garde Gothic"(w) "URW Gothic"(w) "monospace"(w) "Courier"(w) "Nimbus Mono PS"(w) "sans-serif"(w) "sans-serif"(w) "Helvetica"(w) "Helvetica Narrow"(w) "Nimbus Sans Narrow"(w) "monospace"(w) "sans-serif"(w)


Problem:

monospace/serif defaults are assigned too late, `49-sansserif.conf` assigns sans-serif prior, providing sans-serif fallbacks instead of triggering monospace/serif config rules in later configs(including users).

Solution:

Move alias->default rules from `66-noto-*.conf` files to `46-defaults-noto.conf` file, alias-prefer rules should be fine where they are.
This task depends upon

Closed by  Antonio Rojas (arojas)
Tuesday, 10 December 2019, 18:17 GMT
Reason for closing:  Fixed
Additional comments about closing:  noto-fonts 20190926-3

Loading...