I am trying run a docker container with wkthmltopdf 0.12.4 in centos 7. We only want to support "Arial", "Times New Roman" and "Courier New" and do want to deal with msttcorefonts
package. So the liberation fonts packages is close enough. However, It seems like I need to add additional config for it to match correctly.
Inside container it seems like the font is matching as I expected
[root@bafe67a1d200 /]# fc-match 'Arial'
LiberationSans-Regular.ttf: "Liberation Sans" "Regular"
[root@bafe67a1d200 /]# fc-match 'Times'
LiberationSerif-Regular.ttf: "Liberation Serif" "Regular"
[root@bafe67a1d200 /]# fc-match 'Courier New'
LiberationMono-Regular.ttf: "Liberation Mono" "Regular"
But when I tried to convert the following coming from ckEditor with wkhtmltopdf
<span style="font-family:'arial' , 'helvetica' , sans-serif">
This is Arial
</span>
<span style="font-family:Times New Roman,Times,serif;">
This is Times
</span>
<span style="font-family:Courier New,Courier,monospace;">
This is Courier New
</span>
They all come back as LiberationSans in the pdf
However if manually change the font family to the following. It works as expected
<span style="font-family:'Liberation Sans'">This is Arial</span>
<span style="font-family:'Liberation Serif">This is Times</span>
<span style="font-family:'Liberation Mono">This is Courier New</span>
That leads me to believe I might need to add some config in the fontconfig to match the behavior
Here is my docker file
FROM dockerhub.com/jetty
# must be root to install things
USER root
# install wkhtmlpdf and its dependencies
RUN yum install -y libXrender fontconfig libXext && \
wget https://github.com/wkhtmltopdf/wkhtmltopdf/releases/download/0.12.4/wkhtmltox-0.12.4_linux-generic-amd64.tar.xz -O wkhtmltopdf.tar.xz && \
tar -Jxf wkhtmltopdf.tar.xz && \
cp -r wkhtmltox/bin/* /usr/local/bin/ && cp -r wkhtmltox/lib/* /usr/lib/ && cp -r wkhtmltox/include/* /usr/include/ && \
rm wkhtmltopdf.tar.xz && \
# install supported fonts
# - liberation-sans-fonts: Airal
# - liberation-serif-fonts: Times New Roman
# - liberation-mono-fonts: Courier New
yum install -y liberation-fonts-common liberation-serif-fonts liberation-sans-fonts liberation-mono-fonts
# copy the war into jetty to be deployed
COPY maven /opt/jetty-base