Fix: Install Chinese support for linuxserver firefox

This article talks about how to install chinese font “wqy-zenhei” on linuxserver/firefox docker to enable chinese support on docker based firefox.

Question

In this blog post, we introduced how to install firefox in qnap. After installation, we found that the English website can be browsed normally, but the Chinese website are all displayed as squares. It should be that the simplified version of alpine does not have Chinese fonts installed.

Solution steps

  1. Go inside the container
$ ssh admin@192.168.1.2
$ docker exec -it firefox /bin/sh
  1. Modify repository to add @edge repository that contains font library
$ vim /etc/apk/repositories
## Paste the following three lines in the file
http://dl-cdn.alpinelinux.org/alpine/v3.15/main
http://dl-cdn.alpinelinux.org/alpine/v3.15/community
@edge http://dl-cdn.alpinelinux.org/alpine/edge/testing

You can also replace dl-cdn.alpinelinux.org with other faster sources, eg: mirrors.sjtug.sjtu.edu.cn is much faster than dl-cdn.alpinelinux.org in China.

  1. Install fonts wqy-zenhei
$ apk add wqy-zenhei@edge

It’s not finished yet

After the above steps, you can indeed browse Chinese websites normally, but if the container is restarted, the font files will be lost again. Because our fonts are installed in /usr/share/fonts directory, and this directory haven’t mount to any NAS folder. When the container is restarted, /usr/share/fonts will be restored to the state of the container initialization.

  1. Modify the docker-compose file

Create a new font folder locally, for example: /share/Container/firefox/wqy-zenhei, and add the font directory mount under volumes.

volumes:
  - /share/Container/firefox:/config
  - /share/Container/firefox/wqy-zenhei:/usr/share/fonts/wqy-zenhei
  1. Restart the container

Restart the container and repeat the above operations. Now no matter how many times you restart the NAS or container, firefox can display Chinese normally.

Post a Comment

0 Comments