jlesage / docker-firefox

Docker container for Firefox
MIT License
1.42k stars 267 forks source link

Can't display non-English characters #160

Closed cocomany closed 1 year ago

cocomany commented 1 year ago

How to set the browser to support non-English characters, e.g Chinese?

jlesage commented 1 year ago

You need to set the ENABLE_CJK_FONT environment variable. See: https://github.com/jlesage/docker-firefox#environment-variables

gofunn commented 1 year ago

@cocomany Why not use msyh font ? (only 19M, or some other open source fonts)

@jlesage the internet to download CJK font is so slow in china. maybe this is useful?

sed -i 's/dl-cdn.alpinelinux.org/mirrors.aliyun.com/g' /etc/apk/repositories

I use it in WSL

if [ ! -e msyh ];then mkdir msyh;fi
ls /mnt/c/Windows/Fonts/msy*.ttc | xargs -i cp -n {} msyh
docker run -d --name=firefox \
-p 5800:5800 \
-e VNC_PASSWORD=xxx\
-v $(pwd)/config:/config \
-v $(pwd)/msyh:/usr/share/fonts/msyh \
--shm-size 1g \
jlesage/firefox
cocomany commented 1 year ago

You need to set the ENABLE_CJK_FONT environment variable. See: https://github.com/jlesage/docker-firefox#environment-variables

Yes, that works. THank you!

jlesage commented 1 year ago

@gofunn, note that the font installed by the container is about 8.75MB in download size. Also, it needs to be installed once after the creation of the container.

If using ENABLE_CJK_FONT is causing too much trouble, you can, as you suggested, map a font directory to the container. You can also run the following command to install font from a mirror:

docker exec <container name> add-pkg font-wqy-zenhei --repository http://mirrors.aliyun.com/alpine/edge/testing
gofunn commented 1 year ago

Init with -e ENABLE_CJK_FONT=1 \. The target users of CJK_FONT where come from china mainland have a network like this.🤣

[cont-init   ] 10-cjk-font.sh: executing...
[cont-init   ] 10-cjk-font.sh: installing CJK font...
[cont-init   ] 10-cjk-font.sh: fetch http://dl-cdn.alpinelinux.org/alpine/edge/testing/x86_64/APKINDEX.tar.gz
[cont-init   ] 10-cjk-font.sh: WARNING: Ignoring http://dl-cdn.alpinelinux.org/alpine/edge/testing: network error (check Internet connection and firewall)
[cont-init   ] 10-cjk-font.sh: fetch https://dl-cdn.alpinelinux.org/alpine/v3.17/main/x86_64/APKINDEX.tar.gz
[cont-init   ] 10-cjk-font.sh: WARNING: Ignoring https://dl-cdn.alpinelinux.org/alpine/v3.17/main: network error (check Internet connection and firewall)
[cont-init   ] 10-cjk-font.sh: fetch https://dl-cdn.alpinelinux.org/alpine/v3.17/community/x86_64/APKINDEX.tar.gz
[cont-init   ] 10-cjk-font.sh: WARNING: Ignoring https://dl-cdn.alpinelinux.org/alpine/v3.17/community: network error (check Internet connection and firewall)
[cont-init   ] 10-cjk-font.sh: ERROR: unable to select packages:
[cont-init   ] 10-cjk-font.sh:   wqy-zenhei (no such package):
[cont-init   ] 10-cjk-font.sh:     required by: world[wqy-zenhei]
[cont-init   ] 10-cjk-font.sh: terminated with error 1.

There should be a environment variable to set add-pkg MIRROR. I don't want to install it manually after inited the container. It should be easier as docker like this.

curl -fsSL https://get.docker.com -o get-docker.sh
sudo sh ./get-docker.sh --mirror Aliyun