Cover letter with style - part two

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 NFSS1 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. For example, I bought Garamond e Gill Sans fonts from Adobe and I'm using Ubuntu, so I copied the *.otf files somewhere under the

/usr/share/fonts

and then I updated 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/AGaramondPro-Regular.otf | grep Family

Ok, after those few steps I have installed the fonts and discovered their family name, say, "Adobe Garamond Pro" and "Gill Sans Std". Now just change the template (remember, standard.lco) as this:

  1. \ProvidesFile{standard.lco}[%
  2.   2002/07/09 v0.9a LaTeX2e unsupported letter-class-option]
  3.  
  4. \usepackage{fontspec}
  5.  
  6. % ==============================================
  7. %  PERSONAL DATA
  8. % ==============================================
  9. \setkomavar{fromname}{Iulius Caesar}
  10. \setkomavar{fromaddress}{Van Eeghenlaan 69\\1691QT Amsterdam\\Nederland}
  11. \setkomavar{fromphone}{+31 (0)22 7394203}
  12. \setkomavar{fromemail}{iulius@gmail.com}
  13. \setkomavar{fromfax}{+31 (0)71 5144543}
  14. \setkomavar{fromurl}{http://stefano.italians.nl}
  15. \setkomavar{frombank}{Postbank 9307157}
  16. \setkomavar{place}{Amsterdam}
  17. \setkomavar{signature}{Iulius Caesar}
  18.  
  19. % ==============================================
  20. %  FORMATTING STUFF
  21. % ==============================================
  22.  
  23. % === font settings
  24. \defaultfontfeatures{Mapping=tex-text}
  25. \setmainfont {Adobe Garamond Pro}
  26. \setsansfont {Gill Sans Std}
  27.  
  28.  
  29. \endinput

At line 4 I just imported the fontspec package. At line 24 I am instructing fontspec to add the ligatures TeX needs.2 At line 25 I set the main font and at line 26 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. To do so, just add one more line:

  1. \ProvidesFile{standard.lco}[%
  2.   2002/07/09 v0.9a LaTeX2e unsupported letter-class-option]
  3.  
  4. \usepackage{fontspec}
  5.  
  6. % ==============================================
  7. %  PERSONAL DATA
  8. % ==============================================
  9. \setkomavar{fromname}{Iulius Caesar}
  10. \setkomavar{fromaddress}{Van Eeghenlaan 69\\1691QT Amsterdam\\Nederland}
  11. \setkomavar{fromphone}{+31 (0)22 7394203}
  12. \setkomavar{fromemail}{iulius@gmail.com}
  13. \setkomavar{fromfax}{+31 (0)71 5144543}
  14. \setkomavar{fromurl}{http://stefano.italians.nl}
  15. \setkomavar{frombank}{Postbank 9307157}
  16. \setkomavar{place}{Amsterdam}
  17. \setkomavar{signature}{Iulius Caesar}
  18.  
  19. % ==============================================
  20. %  FORMATTING STUFF
  21. % ==============================================
  22.  
  23. % === font settings
  24. \defaultfontfeatures{Mapping=tex-text}
  25. \setmainfont {Adobe Garamond Pro}
  26. \setsansfont {Gill Sans Std}
  27.  
  28. %set the font size and leading
  29. \renewcommand{\normalsize}{\fontsize{12.5}{17}\selectfont}
  30.  
  31. \endinput

I just added the line 29, plain old Latex directive, to redefine the \normalsize macro3. In this way I can specify the height of the font and the space in point between the lines. The values one should use really depend on so many factors... but this is not a course on basic typography.

Ok, time to generate our cover letter again. To appreciate the differences, I first show the old version:

default font

And now with the professional fonts

professional font

Can you see the difference? I hope so. Note also the sender address: it has to be rendered in a smaller size, so KOMA-Script used the sans serif font because more legible; that's why we also specified a suitable family for sans serif font in our template.

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. Now you can proceed to the third part.

  1. New Font Selection Scheme []
  2. Commercial fonts usually lacks ligatures like "--" (n-dash) and "---" (m-dash) but with this line TeX will still find them []
  3. There are other methods []

1 Comment so far

  1. Sagun on August 30th, 2009

    Hi,

    I really appreciate you taking the time to write these tutorials. It shows me new ways to do thing, I had never thought before.

    Could you please some how provide me with a sample code for your completed CV tutorial?

    Thanks

    Sagun

Leave a reply