Fixing broken Japanese fonts on Arch LinuxAugust 30, 2018 -
Setting up fonts for Japanese and other non-latin languages can be a bit difficult on Arch Linux. I find that every time I configure a new system I forget how to make it work perfectly, and I end up wasting hours trying to find the right answers.
So I'm writing this as a reference in case I ever need to do it again.
System font configuration
The first issue I'll normally run into is broken fonts. After finishing up an install, non-latin fonts look like this:
A bit squished. Well this is easily fixed by creating a user font configuration file, at the path
~/.config/fontconfig/fonts.conf, and filling it with the following:
<fontconfig> <alias> <family>serif</family> <prefer> <family>Noto Serif CJK JP</family> </prefer> </alias> <alias> <family>sans-serif</family> <prefer> <family>Noto Sans CJK JP</family> </prefer> </alias> <alias> <family>monospace</family> <prefer> <family>Fantasque Sans Mono</family> <family>Noto Sans Mono CJK JP</family> </prefer> </alias> </fontconfig>
It's important to note that I added my default monospace font into the configuration file as well, above the Japanese mono font.
When Arch Linux tries to match a font, it works it's way down through the list of fonts until it finds one that matches.
As the user specified config is one of the first to be matched, the Noto Sans Mono CJK JP font could be matched quite early, which doesn't look great for English characters.
To combat this, you could not specify a monospace font, or you could edit the system configuration at
I find it's a lot easier having the
~/.config/ folder though, since I can sync it with the rest of my dotfiles.
Finding a way to write Japanese using Linux is probably one of the harder things to do.
When I have to do it, I normally start by installing
uim. After spending an hour or so configuring it, I find out that it doesn't work with QT5 apps.
Following some instructions online I'll end up building a version from the AUR but it still won't work.
After a few more hours of searching online, I'll eventually stumble upon this reddit post which will put me on the right track.
You can find more details about installing
fcitx at the Archlinux Wiki.
fcitx-mozcand the config tool.
sudo pacman -Sy fcitx-im fcitx-mozc fcitx-configtool
echo "GTK_IM_MODULE=fcitx QT_IM_MODULE=fcitx XMODIFIERS=@im=fcitx" >> ~/.pam_environment
After doing those steps, Fcitx and Mozc should both be installed. Go ahead and issue the command
fcitx to start the daemon.
You can now change up the hotkeys or enable auto-starting, but I prefer only executing it when I need to.