You are not logged in.

#1 2022-11-07 16:48:17

luofeiyu
Member
Registered: 2015-11-03
Posts: 30

[SOLVED]Why os don't call desired font to render chinese character

OS and desktop environment info:

[arch@arch ~]$ uname -a
Linux arch 5.15.74-1-lts #1 SMP Sat, 15 Oct 2022 06:43:47 +0000 x86_64 GNU/Linux
[arch@arch ~]$ pacman -Qi  lxterminal | grep Version
Version         : 0.4.0-1
[arch@arch ~]$ pacman -Qi  lxappearance | grep Version
Version         : 0.6.3-4

I want to achieve the target in lxterminal:render English character with "Bitstream Vera Sans Mono"  ,render Chinese character with "Noto Sans CJK SC".
Set "Bitstream Vera Sans Mono" in lxappearance:

https://i.stack.imgur.com/zWivO.png

How can render Chinese character with "Noto Sans CJK SC" in lxterminal then?
It is no use to write below line in /etc/fonts/fonts.conf,OS call other fonts instead of "Noto Sans CJK SC".

    <?xml version="1.0"?>
    <!DOCTYPE fontconfig SYSTEM "urn:fontconfig:fonts.dtd">
    <!-- $XDG_CONFIG_HOME/fontconfig/fonts.conf for per-user font configuration -->
    <fontconfig>    
    <dir prefix="xdg">fonts</dir>    
    <match target="font">
    	<edit name="rgba" mode="assign"><const>rgb</const></edit>
    </match>
    <match>
        <test name="lang" compare="eq">
            <string>en_US</string>
        </test>
        <edit name="family" mode="assign">
            <string>Bitstream Vera Sans Mono</string>
        </edit>
    </match>    
    <match>
        <test name="lang" compare="eq">
            <string>zh_CN</string>
        </test>
        <edit name="family" mode="assign">
            <string>Noto Sans CJK SC</string>
        </edit>
    </match>
    </fontconfig>

Mod Edit - Replaced oversized image with link.
CoC - Pasting pictures and code

Last edited by luofeiyu (2022-11-08 22:58:08)

Offline

#2 2022-11-07 17:12:05

V1del
Forum Moderator
Registered: 2012-10-16
Posts: 25,261

Re: [SOLVED]Why os don't call desired font to render chinese character

The lang param will likely not be generally set and be dependant on your application (I'm assuming this will only truly work with browsers that get language information from webpages) Do aliases for the "normal" monospace family and list all fonts that should be checked for glyphs.  https://wiki.archlinux.org/title/Font_c … tion#Alias

Offline

#3 2022-11-08 08:33:58

luofeiyu
Member
Registered: 2015-11-03
Posts: 30

Re: [SOLVED]Why os don't call desired font to render chinese character

It is no use to set with Alias in ".config/fontconfig/fonts.conf".

<?xml version="1.0"?>
<!DOCTYPE fontconfig SYSTEM "urn:fontconfig:fonts.dtd">
<!-- $XDG_CONFIG_HOME/fontconfig/fonts.conf for per-user font configuration -->
<fontconfig>

<dir prefix="xdg">fonts</dir>

<match target="font">
	<edit name="rgba" mode="assign"><const>rgb</const></edit>
</match>
<match>
    <test name="lang" compare="eq">
        <string>en</string>
    </test>
    <edit name="family" mode="assign">
        <string>Hack</string>
    </edit>
</match>

<match>
    <test name="lang" compare="eq">
        <string>zh</string>
    </test>
    <edit name="family" mode="assign">
        <string>Microsoft YaHei</string>
    </edit>
</match>
  <alias>
    <family>serif</family>
    <prefer>
      <family>Microsoft YaHei</family>
    </prefer>
  </alias>
  <alias>
    <family>sans-serif</family>
    <prefer>
      <family>Microsoft YaHei</family>
    </prefer>
  </alias>
  <alias>
    <family>monospace</family>
    <prefer>
      <family>Microsoft YaHei</family>
    </prefer>
  </alias>
</fontconfig>

So strange that any chinese character in lxterminal was rendered by a kind of Japanese font "YuGothic",i pointed to "Microsoft YaHei" to render ,but can't work!

fc-list | grep YaHei
/usr/share/fonts/msfonts/msyhl.ttc: Microsoft YaHei UI,Microsoft YaHei UI Light:style=Light,Regular
/usr/share/fonts/msfonts/msyh.ttc: Microsoft YaHei,微软雅黑:style=Regular,Normal,obyčejné,Standard,Κανονικά,Normaali,Normál,Normale,Standaard,Normalny,Обычный,Normálne,Navadno,Arrunta
/usr/share/fonts/msfonts/msyhl.ttc: Microsoft YaHei,微软雅黑,Microsoft YaHei Light,微软雅黑 Light:style=Light,Regular
/usr/share/fonts/msfonts/msyhbd.ttc: Microsoft YaHei,微软雅黑:style=Bold,Negreta,tučné,fed,Fett,Έντονα,Negrita,Lihavoitu,Gras,Félkövér,Grassetto,Vet,Halvfet,Pogrubiony,Negrito,Полужирный,Fet,Kalın,Krepko,Lodia
/usr/share/fonts/msfonts/msyh.ttc: Microsoft YaHei UI:style=Regular,Normal,obyčejné,Standard,Κανονικά,Normaali,Normál,Normale,Standaard,Normalny,Обычный,Normálne,Navadno,Arrunta
/usr/share/fonts/msfonts/msyhbd.ttc: Microsoft YaHei UI:style=Bold,Negreta,tučné,fed,Fett,Έντονα,Negrita,Lihavoitu,Gras,Félkövér,Grassetto,Vet,Halvfet,Pogrubiony,Negrito,Полужирный,Fet,Kalın,Krepko,Lodia

The image shows that English word were rendered by "Hack" font and Chinese characters are rendered by "YuGothic" instead of "Microsoft YaHei".   

hYVi8.png

Last edited by luofeiyu (2022-11-08 08:45:44)

Offline

#4 2022-11-08 08:59:48

V1del
Forum Moderator
Registered: 2012-10-16
Posts: 25,261

Re: [SOLVED]Why os don't call desired font to render chinese character

Try adding

 <edit name="family" mode="append">
        <string>Microsoft YaHei</string>
    </edit>

to your match for lang=en.

Last edited by V1del (2022-11-08 09:01:24)

Offline

#5 2022-11-08 10:45:09

luofeiyu
Member
Registered: 2015-11-03
Posts: 30

Re: [SOLVED]Why os don't call desired font to render chinese character

It works as V1del say.

<match>
    <test name="lang" compare="eq">
        <string>en</string>
    </test>
    <edit name="family" mode="assign">
        <string>Hack</string>
    </edit>
    <edit name="family" mode="append">
        <string>Microsoft YaHei</string>
    </edit>
</match>

I have never think of the logic behind the code,if English character matched than two kinds of font--(Hack,Microsoft YaHei) called ,how Chinese characters be treated as English characters?
I am puzzled,please give a explanation.

Offline

#6 2022-11-08 13:24:14

seth
Member
From: Won't reply 2 private help req
Registered: 2012-09-03
Posts: 76,427

Re: [SOLVED]Why os don't call desired font to render chinese character

V1del wrote:

The lang param will likely not be generally set and be dependant on your application

Please always remember to mark resolved threads by editing your initial posts subject - so others will know that there's no task left, but maybe a solution to find.
Thanks.

Offline

Board footer

Powered by FluxBB