I'm trying to recreate a pleasing page layout from an existing pdf as a way to get more familiar with book design in latex.

The geometry part was fairly simple to get right, but I've come across a strange phenomenon related to font apperence: On-screen the original looks wonderful while my version seems to have a much darker color and doesn't look nearly as nice even though I've closely matched the dimensions, leading, line-breaks and (natrually) the body font. If I zoom-in the visual difference disappears. xelatex and fontspec were used to generate the PDF and the font is in OpenType Format.

After investigating I discovered that turning off the "text hinting" option (I'm using okular on Linux) makes both versions appear identical, while turning it back on improves the appearence of the original dramatically yet has only a negligable effect on my version.

Obviously, the hinting information in my version is either different or missing then what's used by the original.

What can I do to correct this? How can I inspect the files to figure out what's going on? What should I be looking for?


1 Answer 1


It seems the OTF file I was using lacked hinting information. a search brought me across the (crowed-sourced!) ttfautohint project which automatically adds hinting information to font files using the autohinter algorithm included in the freetype library. After compiling the tool, I had to use fontforge to convert the font into an acceptable format for use with ttfautohint. After running the tool to regenerate the font file and making sure it's picked up by xelatex, recompiling the file results in output that looks much better and is very close to the original I was trying to recreate.

I never realized what a dramatic effect hinting has on on-screen viewing.

Apperently on linux it's also possible to turn on and control hinting on a per font basis with fontconfig, but I haven't looked into it. Having the data embedded in the PDF is the right way to go in any case.


As hosni noted in the comments, fontforge has autohinting capability built-in and Adobe has made publically available the afdko which includes the autohint tool. I'm quite satisfied with the results from ttfautohint.

Edit 2: The steps I took (otf to ttf em=2048 with fontforge, then running ttfautohint) gave me a ttf format font which produced acceptable results. Opening the font back in fontforge and converting it back to otf (cff) then recompiling again seemed to provide no hinting effect, just like the hinted results from afdko. This leads me to believe that there's something else at work which prevents otf (cff) hints from rendering properly. It may be an OS/library/viewer issue rather then the fonts themselves, I do not know and it seems out of place to explore on TeX.se.

I can say that I got satisfactory results by going to ttf and using ttfautohint using fedora as an OS and okular as the viewer. YMMV.

  • 1
    If the original font was a PostScript one (Type 1, OTF etc.) you might want to use a PostScript autohinter instead, like the FontForge one or the one included in AFDKO instead of converting the font to TrueType for use with ttfautohint. May 15, 2014 at 6:32
  • Thanks, I was not aware of either possibility. However, fontforge has the mentu item disabled for some reason and AFDK's autohint did not produce visual results comparable to ttfautohint's output. It may be issues with the specific file, or a question of specifying the correct commandline option (surely, adobe knows how to hint fonts...) but I was unable to get good results.
    – user51756
    May 15, 2014 at 16:49

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.