There is an article until I take a screenshot, but I couldn't find an article in Japanese that I did until I set an arbitrary font, so I wrote it.
All sources are here https://github.com/frkwy/xvfb_screenshot_on_docker
The fonts and sentences used this time are [High school girl style? Download the cute extra-fine font "JK Gothic L" | Font and Cute font [http://font.cutegirl.jp/jk-font-light.html) Aozora Bunko Natsume Soseki I am a cat I used.
The solution is to raise the priority of the font you want to use.
fc-list
: Font list If it is not here, the font is not installed.
This time it's Firefox
It's OK if the font you want to use when you execute fc-match -s sarif
is at the top.
For that, we will create font.conf.
Dockerfile
FROM alpine:latest
COPY fonts.conf /root/.config/fontconfig/
# Please override your favorite font file path
COPY JKG-L_3.ttf /root/.local/share/fonts/
RUN apk update && apk add python3 xvfb firefox dbus && rm -rf /var/cache/apk/*
RUN python3 -m ensurepip
RUN pip3 install --upgrade pip selenium xvfbwrapper
RUN fc-cache -fv
CMD ["python3", "/host/example.py"]
font.conf
Assuming that the font is already installed in the above Dockerfile,
Bring the priority of the font you want to use to the top with binding =" strong "
.
<?xml version="1.0"?>
<!DOCTYPE fontconfig SYSTEM "fonts.dtd">
<fontconfig>
<match target="pattern">
<edit name="family" mode="assign" binding="strong">
<string>JK Gothic L</string>
</edit>
</match>
</fontconfig>
This is a screenshot actually taken.
Recommended Posts