Skip to content
This repository has been archived by the owner on Apr 3, 2020. It is now read-only.

Commit

Permalink
Fix font kerning in container
Browse files Browse the repository at this point in the history
There is a known *issue in Debian distros around subpixel 
hinting & font smoothing. Link below provides a description
& an example font configuration for fixing it.

This was highlighted in the **below wkhtmltopdf issue.

The font configuration(according to the Readme found in
`fonts/config.d/`) relies on ordering hence the `10-` prefix.


*  https://wiki.debian.org/Fonts#Subpixel-hinting_and_Font-smoothing

** wkhtmltopdf/wkhtmltopdf#45
  • Loading branch information
Dan Palmer committed Mar 3, 2016
1 parent ec1c816 commit 3778e6d
Show file tree
Hide file tree
Showing 3 changed files with 32 additions and 1 deletion.
1 change: 1 addition & 0 deletions Dockerfile
Expand Up @@ -9,6 +9,7 @@ RUN rm -rf wkhtmltox

RUN cp -r ./fonts/liberation_sans /usr/share/fonts/truetype/
RUN fc-cache -f -v
RUN cp ./fonts/10-wkhtmltopdf.conf /etc/fonts/conf.d/

ENV UNICORN_PORT 3000
EXPOSE $UNICORN_PORT
Expand Down
3 changes: 2 additions & 1 deletion README.md
Expand Up @@ -21,7 +21,8 @@ machine. You can find the relevant fonts in the `fonts/` directory. You should
be able to add them to OS X by double clicking the font.

The `Dockerfile` is responsible for setting up the fonts from the repo on the
container.
container. It also includes a font configuration file required to fix font
hinting and anti-aliasing in the container when generating PDF's.

### `Environment Variables`

Expand Down
29 changes: 29 additions & 0 deletions fonts/10-wkhtmltopdf.conf
@@ -0,0 +1,29 @@
<?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>

0 comments on commit 3778e6d

Please sign in to comment.