Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

无法设置中文 #14

Open
AomaYple opened this issue Apr 14, 2023 · 7 comments
Open

无法设置中文 #14

AomaYple opened this issue Apr 14, 2023 · 7 comments

Comments

@AomaYple
Copy link

屏幕截图 2023-04-14 141516

@mingkeYao
Copy link

不用设置中文,直接参考arch官方文档安装中文字体,就能显示中文了

@AomaYple
Copy link
Author

不用设置中文,直接参考arch官方文档安装中文字体,就能显示中文了

那能让终端输出中文吗

@mingkeYao
Copy link

捕获

终端不行,一些图形化软件里面是可以显示中文的

@AomaYple
Copy link
Author

捕获

终端不行,一些图形化软件里面是可以显示中文的

怎么配置输入法呀

@nzlov
Copy link

nzlov commented Apr 16, 2023

/etc/pacman.conf

[options]

这部分删除,然后执行

pacman -Syu glibc

@AomaYple
Copy link
Author

AomaYple commented Apr 16, 2023

/etc/pacman.conf

[options]

这部分删除,然后执行

pacman -Syu glibc

执行locale -a仍然没有zh_CN.UTF-8

@PandaRyshan
Copy link

我是自己安装的 arch,没有用这个软件里的包,根据我的经验,不用设置 locale,如果要设置的话,大多数情况使用 C.UTF-8 就够了,除非有些软件依赖于特定 LANG 或者 LC 设置的话。可以自己在 bashrc 或者其他 shell 的环境中配置如下内容:

# $HOME/.bashrc or $HOME/.zshrc etc...
export LANG="C.UTF-8"
export LC_CTYPE="C.UTF-8"
export LC_ALL="C.UTF-8"

# ... other LC export

至于中文的显示主要还是字体,可以参考一下这两篇文档,简体中文本地化字体设置

这里捡重点说,你首先需要安装至少一个支持中文的字体,比如:

sudo pacman -S noto-fonts

然后在 $HOME/.fonts.config.d/$HOME/.config/fontconfig/conf.d/ 下放置自己的字体配置文件:

mkdir -p $HOME/.fonts.config.d
touch $HOME/.fonts.config.d/50-user.conf

用你擅长的文本编辑器修改配置文件,添加默认字体配置。以下是一个示例:

<?xml version="1.0"?>
<!DOCTYPE fontconfig SYSTEM "urn:fontconfig:fonts.dtd">
<fontconfig>
  <match target="pattern">
    <test name="family">
      <string>system-ui</string>
    </test>
    <edit name="family" mode="prepend" binding="strong">
      <string>Cascadia Mono</string>
      <string>Noto Sans Mono</string>
    </edit>
  </match>

  <!-- Default sans-serif fonts-->
  <match target="pattern">
    <test name="family">
      <string>sans-serif</string>
    </test>
    <edit name="family" mode="prepend" binding="strong">
      <string>Cascadia Mono</string>
      <string>Noto Sans Mono</string>
    </edit>
  </match>

  <!-- Default serif fonts-->
  <match target="pattern">
    <test name="family">
      <string>serif</string>
    </test>
    <edit name="family" mode="prepend" binding="strong">
      <string>Cascadia Mono</string>
      <string>Noto Sans Mono</string>
    </edit>
  </match>

  <!-- Default monospace fonts-->
  <match target="pattern">
    <test name="family">
      <string>monospace</string>
    </test>
    <edit name="family" mode="prepend" binding="strong">
      <string>Cascadia Mono</string>
      <string>Noto Sans Mono</string>
    </edit>
  </match>
</fontconfig>

这里的配置文件会覆盖 /etc/fonts/conf.d/50-user.conf ,除非你想做全局的更改,否则不要去动 /etc/fonts 下的配置。这里为三种不同类型的字体配置了两个默认项,会根据顺序自动选择。这样设置后,一般情况下无论是在 shell 还是 gui 程序中都能正确显示字体了。

vineelsai26 added a commit that referenced this issue Mar 2, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants