适用于centos 7

时间:2017-09-29 16:45:48

标签: fonts ckeditor dockerfile wkhtmltopdf fontconfig

我正在尝试使用wkthmltopdf 0.12.4在centos 7中运行一个docker容器。我们只想支持" Arial"," Times New Roman"和" Courier New"并且想要处理msttcorefonts包。所以解放字体包足够接近。但是,似乎我需要添加额外的配置才能正确匹配。

在容器内部,似乎字体与我预期的匹配

[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"

但是当我尝试使用wkhtmltopdf

转换来自ckEditor的以下内容时
<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>

他们都在pdf

中作为LiberationSans回归

但是,如果手动将字体系列更改为以下内容。它按预期工作

<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>

这让我相信我可能需要在fontconfig中添加一些配置来匹配行为

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

0 个答案:

没有答案