Sharing fonts from host to docker instance
As part of writing html_to_pdf.sh for programatically printing a webpage to PDF format, I encountered the problem of fonts appearing differently after having been output as PDF. Further investigation revealed the alpine-chrome
Docker image did not have the fonts being used in the HTML document.
A simple solution—replace /usr/share
font directories in the Docker image with those of the host:
docker run --rm \
-v /usr/share/fonts:/usr/share/fonts \
-v /usr/share/fontconfig:/usr/share/fontconfig \
asia.gcr.io/zenika-hub/alpine-chrome
And it works!