This is the second part of the tutorial Cover letter with style. You can find the first part here.
In this second part, we will change the default fonts using
fontspec. Forget importing Postscript fonts, classifying them under the NFSS (New Font Selection Scheme) and other crazy stuff: fontspec is able to load opentype fonts and select them very easily. You have just to install the fonts on your system, if not already present. And please do yourself a favour: buy an handful of professional fonts.
On Mac is trivial to install fonts. If you are using Ubuntu, you can copy the *.otf files somewhere under the
/usr/share/fonts and then update the font cache with this command:
$ sudo fc-cache -fv
Last thing you will need is to take note of the exact name of the font family, to be able to select it. For that, after having installed the
lcdf-typetools ubuntu package, you can do something like
otfinfo -i /usr/share/fonts/<<your font file>>.otf | grep Family
Ok, assuming you have your font installed and you know its name, you can change the letter template (remember,
standard.lco) as the following:
At line 5 I just imported the fontspec package. At line 26 I am instructing fontspec to add the mapping for TeX ligatures, like – (n-dash) and — (m-dash). At line 27 I set the main font and at line 28 I set the font to be used in case a sans serif one if needed.
Another important thing to set up, usually, is the font size and the lead. That’s the purpose of line 31. It is a plain old Latex directive, to redefine the
\normalsize macro. In this way I can specify the height of the font and the space in points between the lines. The values one should use really depend on so many factors! Alas, this is not a course about typography.
Ok, time to generate our cover letter again. You might see some warnings in the log:
Translated, it means that the Computer Modern font is being scaled. It is used as default math font. Since we don’t plan to write math formulas in our cover letter, we can ignore the warnings. Or simply add the following line to the template:
If you need math fonts, you should avoid the workaround and use Latin Modern, which can be scaled at whatever size, or other similar fonts.
Ok, let’s try again to generate the pdf. If you used a good font, you should notice the difference. Here I’m using Adobe Garamond Pro (at the bottom)
Can you see the difference? I hope so.
For more information, examples and so on, I urge you to read the fontspec documentation, to get ready for the third part of the tutorial.
That’s all folks.