Resolving fonts on Linux (CentOS 5 and 6)

1,850 views
Skip to first unread message

Yozons eSignForms

unread,
Apr 23, 2014, 12:40:50 AM4/23/14
to wkhtmltop...@googlegroups.com
Can anybody explain how wkhtmltopdf resolves fonts under Linux?  I am running both CentOS 5 and 6 servers, and I can't seem to make true type fonts under CentOS 5 look good even for simple fonts like Arial and Times New Roman.

Just for grins, I copied my C:\Windows\Fonts\*.ttf (under Windows 7) to a /usr/share/fonts/WindowsFonts folder and renamed them to all lowercase letters.

Then I ran fc-cache -fv and noted that it seemed to process them with this output:
         /usr/share/fonts/WindowsFonts: caching, 381 fonts, 0 dirs

Then I ran fc-match -v "Arial" and fc-match-v  "Times New Roman" and both pointed to the files I just installed:
        file: "/usr/share/fonts/WindowsFonts/arial.ttf"(s)

But when I run wkhtmltopdf (versions 0.10, 0.11, 0.12), the fonts appear no better, with the kerning issues that make the letters mostly get scrunched together, and a few with too much whitespace between them.  I tried setting to "wingdings" and it did show them, so it's sort of like it's installed.

Allan Jardine

unread,
Jul 21, 2014, 6:56:02 AM7/21/14
to wkhtmltop...@googlegroups.com
I know I'm replying to a thread from a few months back now, but I'm also seeing this behaviour with the current wkhtmltopdf release (0.12.1 at the time of writing) with CentOS 6. I have a TTF font installed on the machine and referenced in the CSS, but the PDF generated isn't using it. Running wkhtmltopdf on a Mac with the same page and font works perfectly).

Is there a way to see what font's wkhtmltopdf is using? I had a look for a verbose mode but didn't see one.

Thanks,
Allan

Yozons eSignForms

unread,
Jul 21, 2014, 12:56:43 PM7/21/14
to wkhtmltop...@googlegroups.com
Does this find your font? fc-match -v "Font Name"

Our kerning issue was resolved with issues 45 fontconfig .conf file we documented for our needs here
https://code.google.com/p/openesignforms/wiki/wkhtmltopdf


Allan Jardine

unread,
Jul 23, 2014, 7:29:39 AM7/23/14
to wkhtmltop...@googlegroups.com
Hi,

Thanks for the reply. The `fc-match` command does indeed find the font (HelveticaNeue in this case). I hadn't seen the link you gave before, but I've gone through the instructions there and all of the packages required do appear to be installed.

This is the page I'm using as a test (a stripped down invoice): http://datatables.net/dev/wkhtmltopdf-test/

And this is the resulting PDF when I run it on CentOS 6.5 with wkhtmltopdf 0.12.1: http://datatables.net/dev/wkhtmltopdf-test/out.pdf

Do you have any ideas of what might be doing wrong here? Is there any way I can get some debug information out from wkhtmltopdf?

Thanks,
Allan
Message has been deleted

Allan Jardine

unread,
Jul 31, 2014, 8:44:02 AM7/31/14
to wkhtmltop...@googlegroups.com
Hi,

Just wondering if there is anything I can do to help move this along. Happy to pay for professional services if you offer such support for wkhtmltopdf?

Allan

Yozons eSignForms

unread,
Aug 1, 2014, 7:10:55 PM8/1/14
to wkhtmltop...@googlegroups.com
Could have sworn I replied to this earlier.  We are on CentOS 6.4 and wkhtmltopdf 0.12.1 and I ran your URL as:

wkhtmltopdf http://datatables.net/dev/wkhtmltopdf-test/ test.pdf

And attached is the test.pdf that looks okay. 

A key feature may be the /etc/fonts/conf.d/10-wkhtmltopdf.conf setup if you haven't already done so:
<?xml version='1.0'?>
<!DOCTYPE fontconfig SYSTEM 'fonts.dtd'>
<fontconfig>
 <match target="font">
  <edit mode="assign" name="rgba">
   <const>rgb</const>
  </edit>
 </match>
 <match target="font">
  <edit mode="assign" name="hinting">
   <bool>true</bool>
  </edit>
 </match>
 <match target="font">
  <edit mode="assign" name="hintstyle">
   <const>hintslight</const>
  </edit>
 </match>
 <match target="font">
  <edit mode="assign" name="antialias">
   <bool>true</bool>
  </edit>
 </match>
  <match target="font">
    <edit mode="assign" name="lcdfilter">
      <const>lcddefault</const>
    </edit>
  </match>
</fontconfig>
test.pdf

Allan Jardine

unread,
Aug 4, 2014, 10:50:09 AM8/4/14
to wkhtmltop...@googlegroups.com
Thanks for the reply! That certainly helped a lot. The kerning issues look like they have been resolved, but the font weight is still work. Actually, I can't see to get the font to render in anything other than Helvetica Neue now. I've tries serif font's just to make the change really obvious, and also loading an woff font file but to no avail.

I've just trying installing phantomjs to see what it would output, but the results were rather poor with the kerning issuing being present.

I think I might need to park this until I can dig around my headless CentOS server a bit to see what is going on with the fonts.

Thanks for the help though.

Allan

icand...@gmail.com

unread,
Apr 9, 2018, 1:41:44 PM4/9/18
to wkhtmltopdf General
Yozons, I've been trying to solve this for like a year! No other thread has this solution, thank you. 
Reply all
Reply to author
Forward
0 new messages