Fixing inconsistent japanese fonts - is renaming the file safe?

hey~~

i’ve noticed that whenever i type in japanese some characters are slightly different than others, notably 一 and 体


the font packages i’m using are adobe-source-han-sans-cn-fonts, adobe-source-han-sans-jp-fonts and adobe-source-han-sans-kr-fonts all on version 2.004-1.

in /etc/fonts/conf.d/ there’s these symlinks:

44-source-han-sans-cn.conf@      --> /usr/share/fontconfig/conf.avail/44-source-han-sans-cn.conf
44-source-han-sans-jp.conf@      --> /usr/share/fontconfig/conf.avail/44-source-han-sans-jp.conf
44-source-han-sans-kr.conf@      --> /usr/share/fontconfig/conf.avail/44-source-han-sans-kr.conf

i don’t have a lot of knowledge of chinese but i assume those characters are used in chinese too so the characters i write are then shown with cn fonts since it’s higher than jp. would it be a bad thing if i renamed the symlink to 43-source-han-sans-jp.conf so it’s higher? or is there a different way i should go about this?

Can’t you set it by adjusting fontconfig?
Or is this the result of having already messed with it?
I don’t need Chinese or Korean fonts, so I either delete those fonts or install and configure a completely different Japanese font.
For example, Morisawa BIZ UDP Gothic.

With fontconfig, you can set which font to use if the language you are currently using matches Japanese (ja), so if you need Korean or Chinese, you can use that font by switching with IME. (Uncertain information).
Of course you need to configure it.
However, I think you’ll be happier if you just use Japanese (and English) as simply as possible.

fontconfigをいじったら行けるとかの話ではなくて?
それとも既にいじった状態でそういう結果なのでしょうか?
僕には中国語も韓国語も不要なのでそれらフォント自体を削除してしまうか、全く別の日本語フォントをインストールして設定してしまいます。
例えばモリサワのBIZ UDPゴシックとか。

fontconfigでは、日本語(ja)に今利用している言語がマッチしたらどのフォントを使うかを設定できますので、韓国語や中国語が必要な場合はIMEで切り替えたらそのフォントが使えるかと思います(不確かな情報)。
もちろんそれ用の設定が必要です。
ただ、できるだけシンプルに日本語(と英語)だけ使う方が何かと幸せになれるかと思います。

Arch wiki - ja - fontconfig / samples

morisawa-biz-ud-gothic | Github

i don’t have a user fontconfig, everything is on the default settings, i have not messed with fonts at all.
i like my current japanese font - i’ll probably just remove the cn and kr fonts then, i don’t know chinese or korean. they just got installed when i first installed the system and i kept them.

The font paths used by Fontconfig are /usr/share/fonts/ and ~/.local/share/fonts.
If you don’t have fontconfig, just create it.
However, in the article that describes the settings, there is a path such as $XDG_CONFIG_HOME/fontconfig/fonts.conf, so after creating fontconfig in the hidden folder .config and creating fonts.conf in it, you just need to write the xml that matches the sample.
In other words, the settings written in font.conf will check the fonts in /usr/share/fonts/ or ~/.local/share/fonts.

Arch wiki - Font configuration

I don’t know why the fonts are displayed differently depending on the kanji and compound words in the attached image, but in Japanese, it is possible to mix emergency kanji with common Japanese kanji.

Example 1) The weather is nice today.
今日は良い天気です。
今日は良い天气です。

Example 2) an enemy has appeared
敵が現れた
敌が现れた

The sentences on the top line are all sentences using Japanese common kanji, and the sentences on the bottom line are kanji changed to the kanji used in China.
Even though these are the same kanji, they may be displayed as different characters because they are different in Unicode etc.
For example, even if a Chinese person reviews a product in Japanese on Amazon, they may use kanji that are not commonly used in Japanese, so you can easily tell that the review was not written by a Japanese person.

By the way, even on systems where Japanese, Chinese, and Korean fonts are installed, if input and conversion are done correctly, the text will be displayed in Japanese fonts.
Please check if they are correct before setting fontconfig.

In order to check whether the problem you are asking is due to the system settings or whether the Japanese input or conversion is incorrect, I will post the input and conversion using the correct common kanji, so it will be displayed correctly. Please check.
If it appears correctly, please check that your input is correct.

一二三 いち に さん ichi ni san
絶体絶命 ぜったいぜつめい zettaizetumei
絶 zetu
体 tai
命 mei

Hello,
I use a cjk font (wqy-microhei-patched) for esthetic only and these characters look like this :

https://imgur.com/iOwe32q.png

i copied the characters from your post, here is how they look om my system:

i am using fcitx5-mozc for input and it seems like my conversion is correct but the chinese font is actually used for all the text instead (i can see 絶 in the picture above being drawn using the chinese font variant)

i think that chinese fonts are used because of the rule priority and that seems to be connected to this font behavior, that’s why i wanted to see if i can just safely move the japanese font to a lower number so the rule is processed sooner.
Arch wiki - Font configuration - Rule priority

is that an all in one font for chinese, japanese and korean? the issue on my system appears to be the chinese font rule provided by the ..sans-cn package taking place sooner than japanese. i could just get a similar font but i’m kinda picky when it comes to cjk fonts and i prefer my current ones.

I understand that you say that Chinese fonts have a higher priority, and I thought that in order to change that, I should change that priority in Fontconfig.

My guess is that the Japanese environment is not set up and the Japanese font is falling back on the kanji and hiragana of the text displayed in the Chinese font.
I thought so when I saw the kanji character “今” in the attached image.
The kanji “今” is entered in Japanese, but the Chinese font is applied.

I tried switching the display of text entered in Japanese with noto sans cjk jp regular, Korean, and other identical cjk fonts, and was able to confirm that the characters displayed were in Japanese font.

Screenshot from 2024-02-02 05-27-03

Of course, elishka is not wrong, as I don’t think non-Japanese people would use a Japanese environment.
I guess elishka thinks this is because of the high priority given to Chinese fonts.

I am sure that the cjk font will give priority to Chinese if it is not entered in Japanese.
That would be the specification of the cjk font, so in order to have only Japanese correctly displayed in the current environment,

  1. type Japanese in a Japanese environment
  2. remove the Chinese fonts (only English and Japanese fonts)
  3. set the font preference in fontconfig to Japanese fonts.

I think these will solve the problem.

Move the cjk fonts from the fonts folder to another folder of your choice,

  • adobe-source-han-sans-jp-fonts.
  • adobe-source-han-serif-jp-fonts

If you install only these in your fonts folder, you will see only Japanese fonts.
One problem, however, is that if the text to be used is already a mixture of Chinese and Japanese, the Chinese may be displayed as □ (tofu).
The cjk font also prevents such fonts from becoming tofu.

Japanese is not environmentally acceptable, but if you are copying text written in Japanese from a web browser or other source, there is no problem using only Japanese fonts.

Yes, the command :

fc-match sans -s

should show the sans fonts list by priority.

i am typing japanese using fcitx5-mozc, the characters i type are the exact same characters as the characters you used so i believe it’s set up correctly, but chinese font is still used (which i assume is because of the rule priority, fc-match -s confirms that the chinese font has higher priority than the japanese one).

i’d prefer my characters didn’t become tofu so i kept all three font packages (cn, jp, kr). regenerating the entire fontconfig seems very tedious for this (my fonts are already managed by kde and are on defaults but the panel does not give me options for changing non-latin fonts) so that’s why i just want to know if messing with font files by renaming the rules is what i should do or if it’s not recommended. i think it would solve the problem if the system loaded the japanese font sooner.

based on this fc-match sans -s confirms that the chinese font has higher priority on my system:

...
SourceHanSansCN-Regular.otf: "Source Han Sans CN" "Regular"
SourceHanSansJP-Regular.otf: "Source Han Sans JP" "Regular"
SourceHanSansKR-Regular.otf: "Source Han Sans KR" "Regular"
...

so i’m wondering if there is an “official” way to reorder the rules or if i’ll break something by simply renaming the respective files.

Creating a new fontconfig may seem troublesome or difficult, but I think it’s the best method because it’s extremely easy and allows you to set fonts without changing the system itself.

The following sites have content that supports multilingual display.
I’m sure you’ve already set up something like that, but here’s an example of fontconfig that you can use as a reference.

How to Configure Multilingual

Extracted part of fontconfig - 3.1. fontconfig Configuration

<?xml version='1.0'?>
<!DOCTYPE fontconfig SYSTEM 'fonts.dtd'>
<fontconfig>
  <!-- Defaults -->
  <alias>
    <family>serif</family>
    <prefer>
      <!-- Priority is given to the order of the serif font families below. -->
      <family>Noto Serif</family>
      <family>Noto Sans Arabic</family>
      <family>Joy Pixels</family>
    </prefer>
  </alias>
  <alias>
    <family>sans-serif</family>
    <prefer>
      <!-- Priority is given to the order of the sans-serif font families below. -->
      <family>Noto Sans</family>
      <family>Noto Sans Arabic</family>
      <family>Fira Sans</family>
      <family>Joy Pixels</family>
    </prefer>
  </alias>
  <alias>
    <family>sans</family>
    <prefer>
      <!-- Priority is given to the order of the sans font families below. -->
      <family>Noto Sans</family>
      <family>Noto Sans Arabic</family>
      <family>Fira Sans</family>
      <family>Joy Pixels</family>
    </prefer>
  </alias>
  <alias>
    <family>monospace</family>
    <prefer>
      <!-- Priority is given to the order of the monospace font families below. -->
      <family>Cascadia Code</family>
      <family>Noto Sans Mono</family>
      <family>Joy Pixels</family>
    </prefer>
  </alias>
</fontconfig>

As you can see, just change the contents of the html (xml) tag.
(Please check the correct name of the font.)
Excerpt:

    <prefer>
      <!-- Priority is given to the order of the serif font families below. -->
      <family>adobe-source-han-sans-jp-fonts</family>
      <family>adobe-source-han-sans-cn-fonts</family>
    </prefer>

On the reference site,
mkdir -p ~/.config/fontconfig
There is a description of command operation from the terminal, but since it is a user folder, I think you can create a new folder directly by right-clicking the mouse.
I think you can create a new document in it and edit it by copying and pasting it in gedit or any text editor of your choice. Then save the file name as fonts.conf.
Alternatively, you can select ~/.config/fontconfig when saving and save it as fonts.conf.

If you experience display problems after doing these things, just delete fonts.conf.
If the user’s fonts.conf is gone, the OS will read the system settings.

According to this :
https://bbs.archlinux.org/viewtopic.php?id=85924

you can delete/move the 44something chinese file.

i gave it a try and i have this config:

<?xml version='1.0'?>
<!DOCTYPE fontconfig SYSTEM 'fonts.dtd'>
<fontconfig>
  <alias>
    <family>serif</family>
    <prefer>
      <family>Noto Serif</family>
    </prefer>
  </alias>
  <alias>
    <family>sans-serif</family>
    <prefer>
      <family>Noto Sans</family>
      <family>Source Han Sans JP</family>
    </prefer>
  </alias>
  <alias>
    <family>sans</family>
    <prefer>
      <family>Noto Sans</family>
      <family>Source Han Sans JP</family>
    </prefer>
  </alias>
  <alias>
    <family>monospace</family>
    <prefer>
      <family>Hack</family>
      <family>Source Han Sans JP</family>
    </prefer>
  </alias>
</fontconfig>

seems like that worked and now the japanese kanji is displayed correctly. thanks!

i reordered the rules and regenerated the font cache but it somehow didn’t fix the font priority issues so i wrote a fontconfig. thanks anyway!

This topic was automatically closed 2 days after the last reply. New replies are no longer allowed.