protonscr

Japanese (CJK?) UI fonts ignore fontconfig settings

steamclosed Steam clientruntime
ValveSoftware/steam-for-linux#10422 · opened 2024-01-23 by hogehoge61 · updated 2024-02-15 · 6 comments · github
Hhogehoge61 2024-01-23 github

Your system information

  • Steam client version (build number or date): 1705720677
  • Distribution (e.g. Ubuntu): Arch Linux (2024-01-23 updated)
  • Opted into Steam client beta?: Yes
  • Have you checked for system updates?: Yes
  • GPU: AMD Radeon RX 580

Steps for reproducing this issue:

  1. (Optional) Copy or symbolically link fonts from Windows
  2. Set the Steam client language setting to "日本語 (Japanese)"
  3. Opt-in to the Steam Beta Updates

beta-zop

On the current Beta channel client, it appears that msgothic.ttc: "MS Gothic" is selected for all of the UI in environments where the fonts were copied from Windows. also, even if I remove the Windows font and fc-cache it, it seems to fall back to a different font than the previous or current Stable.

stable-zop

As shown in the screenshots, this problem does not occur when I run Stable (1705108172) in the exact same environment.

Ssmcv 2024-02-13 github

UI fonts ignore fontconfig settings

Which specific fontconfig settings? Please copy/paste any machine-specific or user-specific fontconfig settings that you have set up?

The container that is now used to run the steamwebhelper is meant to have behaviour similar to Flatpak: it will find fonts in /usr/share/fonts and ~/.local/share/fonts automatically, but those fonts will only be used if an application asks for them by name.

Hhogehoge61 2024-02-14 github

UI fonts ignore fontconfig settings

Which specific fontconfig settings? Please copy/paste any machine-specific or user-specific fontconfig settings that you have set up?

The container that is now used to run the steamwebhelper is meant to have behaviour similar to Flatpak: it will find fonts in /usr/share/fonts and ~/.local/share/fonts automatically, but those fonts will only be used if an application asks for them by name.

/etc/fonts/local.conf
<?xml version='1.0'?>
<!DOCTYPE fontconfig SYSTEM 'fonts.dtd'>
<fontconfig>

<!-- Default font (no fc-match pattern) -->
 <match>
  <edit mode="prepend" name="family">
   <string>IBM Plex Sans JP</string>
  </edit>
 </match>

<!-- Default font for the ja_JP locale (no fc-match pattern) -->
 <match>
  <test compare="contains" name="lang">
   <string>ja</string>
  </test>
  <edit mode="prepend" name="family">
   <string>IBM Plex Sans JP</string>
  </edit>
 </match>

<!-- Default sans-serif font -->
 <match target="pattern">
   <test qual="any" name="family"><string>sans-serif</string></test>
   <!--<test qual="any" name="lang"><string>ja</string></test>-->
   <edit name="family" mode="prepend" binding="same"><string>IBM Plex Sans JP</string>  </edit>
   <edit name="family" mode="append" binding="same"><string>Noto Sans</string>  </edit>
 </match>
 
<!-- Default serif fonts -->
 <match target="pattern">
   <test qual="any" name="family"><string>serif</string></test>
   <edit name="family" mode="prepend" binding="same"><string>IBM Plex Serif</string>  </edit>
   <edit name="family" mode="append" binding="same"><string>Noto Serif</string>  </edit>
   <edit name="family" mode="append" binding="same"><string>IPAPMincho</string>  </edit>
   <edit name="family" mode="append" binding="same"><string>HanaMinA</string>  </edit>
 </match>

<!-- Default monospace fonts -->
 <match target="pattern">
   <test qual="any" name="family"><string>monospace</string></test>
   <edit name="family" mode="prepend" binding="same"><string>PlemolJP Console</string></edit>
   <edit name="family" mode="append" binding="same"><string>IBM Plex Mono</string></edit>
   <edit name="family" mode="append" binding="same"><string>Noto Sans Mono</string></edit>
   <edit name="family" mode="append" binding="same"><string>Inconsolatazi4</string></edit>
   <edit name="family" mode="append" binding="same"><string>IPAGothic</string></edit>
 </match>

<!-- Fallback fonts preference order -->
 <alias>
  <family>sans-serif</family>
  <prefer>
   <family>IBM Plex Sans JP</family>
   <family>Noto Sans</family>
   <family>Open Sans</family>
   <family>Droid Sans</family>
   <family>Ubuntu</family>
   <family>Roboto</family>
   <family>NotoSansCJK</family>
   <family>Source Han Sans JP</family>
   <family>IPAPGothic</family>
   <family>VL PGothic</family>
   <family>Koruri</family>
  </prefer>
 </alias>
 <alias>
  <family>serif</family>
  <prefer>
   <family>IBM Plex Serif</family>
   <family>Noto Serif</family>
   <family>Droid Serif</family>
   <family>Roboto Slab</family>
   <family>IPAPMincho</family>
  </prefer>
 </alias>
 <alias>
  <family>monospace</family>
  <prefer>
   <family>PlemolJP Console</family>
   <family>IBM Plex Mono</family>
   <family>Noto Sans Mono</family>
   <family>Inconsolatazi4</family>
   <family>Ubuntu Mono</family>
   <family>Droid Sans Mono</family>
   <family>Roboto Mono</family>
   <family>IPAGothic</family>
  </prefer>
 </alias>
 <dir>~/.fonts</dir>
</fontconfig>
fc-match
[hogehoge61@META-DESK-ONE ~]$ fc-match sans-serif
IBMPlexSansJP-Regular.ttf: "IBM Plex Sans JP" "Regular"
[hogehoge61@META-DESK-ONE ~]$ fc-match serif
IBMPlexSerif-Regular.ttf: "IBM Plex Serif" "Regular"
[hogehoge61@META-DESK-ONE ~]$ fc-match monospace
PlemolJPConsole-Regular.ttf: "PlemolJP Console" "Regular"

1-zop
Chromium also seems to use MS Gothic by default in the FlatPak version (xdg-config/fontconfig:ro is required to display with the intended font).

Ssmcv 2024-02-14 github

Thanks, that's most of the information I needed.

What do the two screenshots in the most recent comment represent? I can see that there are two Chromium windows, black on the left and grey on the right, and the black one has proportional English text and anti-aliased Japanese, while the grey one has monospaced English text and pixelated Japanese. Is one of them installed at OS level and the other as a Flatpak app, or are they the same Flatpak app with and without --filesystem=xdg-config/fontconfig:ro, or what?

The steamwebhelper (Steam UI) in the beta client is using a vaguely Flatpak-like container (the same Steam Linux Runtime containers used by Proton, Dota 2, CS2) to get a consistent library stack and runtime environment across all Linux distros, while trying to avoid the problems of very old distros (having to choose between the whole ecosystem being held back by users of Ubuntu oldoldoldLTS, or making a very recent distro a hard dependency) or very new distros (regressions and behaviour changes breaking Steam).

[flatpak (run|override) --filesystem=]xdg-config/fontconfig:ro is required to display with the intended font

That's a different configuration location, $XDG_CONFIG_HOME/fontconfig or ~/.config/fontconfig. Do you have additional customizations there?

There are a couple of reasons why sharing these files with the sandbox/container isn't the default for Flatpak apps:

  • because the container has its own version of libfontconfig in order to get predictable behaviour, there's no guarantee that the configuration language understood by your host system's libfontconfig will be understood by the container's libfontconfig;
  • and fontconfig configuration files can contain paths, but inside the container, the meanings of some paths are different (it's a different /usr), so a configuration file that's valid on the host is not necessarily valid in the container

The same reasons apply equally to the Steam Linux Runtime, unfortunately.

For your specific use-case, the only path in your /etc/fonts/local.conf is ~/.fonts, which happens to be shared with the Steam Linux Runtime container by default, and the rules you've set up for selecting fonts are probably valid in arbitrarily old libfontconfig, so sharing the local.conf with the host would probably work? But the same will not be true for everyone, so I think if there was any change to this, it would need either an opt-in or an opt-out mechanism.

It isn't currently possible to override files in /etc in the Steam Linux Runtime container, but if you move or copy your local configuration to ~/.config/fontconfig/fonts.conf then that should work. I tried changing that file on a test system to have a simplified configuration change:

<fontconfig>
<alias>
<family>sans-serif</family>
<prefer>
<family>Hack</family>
</prefer>
</alias>
</fontconfig>

(where Hack is a visually distinctive font that I have installed); and some elements of the Steam UI, notably the Wishlist button on the Store page, changed to that font.

Hhogehoge61 2024-02-15 github

What do the two screenshots in the most recent comment represent? I can see that there are two Chromium windows, black on the left and grey on the right, and the black one has proportional English text and anti-aliased Japanese, while the grey one has monospaced English text and pixelated Japanese. Is one of them installed at OS level and the other as a Flatpak app, or are they the same Flatpak app with and without --filesystem=xdg-config/fontconfig:ro, or what?

On the left in the screenshot is extra/chromium installed on Arch Linux with pacman. On the right is Chromium on Flatpak ('--filesystem=xdg-config/fontconfig:ro` without) and the image compares the two. (Sorry for the lack of necessary explanation).

The differences in window themes are simply to make it easier to understand that each is a different instance.

[flatpak (run|override) --filesystem=]xdg-config/fontconfig:ro is required to display with the intended font

That's a different configuration location, $XDG_CONFIG_HOME/fontconfig or ~/.config/fontconfig. Do you have additional customizations there?

There was a lack of explanation and an error here as well. This is only valid if you put the equivalent setting in ~/.config/fontconfig/fonts.conf and is the workaround I use for the Flatpak application on Steam Deck.

And as you pointed out, simply cp /etc/fonts/local.conf ~/.config/fontconfig/fonts.conf got the font display I intended. I should have realized that Steam Deck, which is configured in ~/.config/fontconfig/fonts.conf would display the correct fonts. Sorry for the trouble.

TTTimo 2024-02-15 github

Thank you, this will be useful to other users with local customizations to their fontconfig configuration. For now the best way is to use ~/.config/fontconfig/fonts.conf

Ssmcv 2024-02-15 github

This is an example of a more general pattern in the Steam Linux Runtime: it will often try to make use of per-user customizations but not system-wide customizations.

(This is because system-wide customizations are hard to distinguish from parts of the operating system design that are not compatible with the container, so bringing them into the container is a higher regression risk than for per-user customizations.)

Nothing extracted yet.