Setup Handwritten Fonts for TexLive



For a current project, I want to create letters in LaTeX, that look as if they where handwritten.
This poses two problems: At first we need to install a font, that looks like hand writing.
Secondly, we need a tool, to randomise some aspects of the writing, such as the position in the line, and the font size, within certain variables.

Luckily, the handlatex package offers exactly that.

Download a handwritten font

I found this font, which is free for non-commercial and even commercial use, that suits my needs:
Aquiline-Two (click on the license tab to see the license).


Install handwritten font

First we need to install the font. If you want to do this locally, it's fairly easy:

mkdir -p ยจ/.local/share/fonts/ttf
cp *.ttf ~/.local/share/fonts/ttf
fc-cache -fv

That's all there is to it!

Install Handlatex

The handlatex tool is a set of scripts that works as a wrapper around the pdflatex command. It randomizes certain settings, such as line position or font size, to make a font look handwritten.

To get the package, you need to install subversion; in Arch-Linux for example with:
sudo pacman -S subversion

Then you can download and install the package
cd ~/Projects
svn checkout handlatex
cd handlatex

We need to install the python script. The handlatex package uses python 2.7, so on most modern Linux systems, we need to call the python2 command, instead of python.

sudo python2 install

If python 2.7 is your default, use

sudo python install

Now we need to create the .sty files

pdflatex hand.ins
pdflatex hand.dtx

Now we need to copy the style files into our local ~/texmf folder, to make it visible to latex.

cd ..
mv handlatex ~/texmf/tex/latex

Now the handlatex command can be used on any latex project:
handlatex MyDocument.tex

Modifying the wscript file

I use the the SoftwareLaTeXMakefile WAF Build System to create my documents. To run it properly, I have to modify the wscript file to meet our needs. Change the conf_tex() method in the ./wscript file:

  1. def conf_tex(ctx):
  2.     ctx.find_program('handlatex', var='TEX')
  3.     ctx.env.TEXINPUT = ctx.path.abspath() + '//'

And change the build_tex() function in ./wscript to the following:
  1. def build_tex(ctx):
  2.     for f in ctx.env.SOURCEFILES :
  3.         ctx(rule='TEXINPUTS=${TEXINPUT}: ${TEX} ${SRC} >/dev/null && rm -f ../*.h*',source=f)
  4.         if ctx.cmd == 'install':
  5.             fileName, fileExt = os.path.splitext(f)
  6.             ctx.install_files('${PREFIX}',fileName + '.pdf'

Example how to use it

This is the example document, using the Aquiline-Two font.

Example.tex (line 1)
  1. documentclass{article}
  3. % Sample demo document for handLatex using TeX Live' xelatex driver.
  5. \usepackage[xetex,
  6.   bookmarks=false,
  7.   pdftitle={handLaTeX demo}]{hyperref}
  8. \usepackage{fontspec}
  10. \usepackage[driver=xelatex,
  11.   lowwordangle=-3,
  12.   highwordangle=3,
  13. ]{hand}
  14. \usepackage{amssymb}
  16. \begin{document}
  17. \thispagestyle{empty}
  19. \section*{\texttt{hand}\LaTeX\ Demo}
  20. \fontspec{AquilineTwo} % If you have any good font, include it here.
  22. \vfill
  24. \begin{handpar}
  25. Lorem ipsum dolor sit amet, consectetuer adipiscing elit. Duis ut libero et arcu
  26. interdum varius. Nam bibendum, mi sed consequat malesuada, nunc diam condimentum
  27. massa, sit amet egestas nibh ligula sit amet dui. Vestibulum eu urna. Etiam
  28. vestibulum. Aenean nisi nulla, fringilla at, laoreet eu, iaculis id,
  29. diam. Mauris aliquet vehicula lacus. Maecenas id nisl ac justo sodales
  30. dictum. Phasellus eget eros. In hac habitasse platea dictumst. Nam ut tortor
  31. vitae dui mollis egestas. Nullam sagittis libero quis nibh. Donec aliquam. Donec
  32. tincidunt. Aliquam eget nisl. Suspendisse mollis pellentesque nunc.
  33. \end{handpar}
  35. \begin{handpar}
  36. Praesent non urna. Proin suscipit felis vel arcu. Etiam gravida ante id
  37. ligula. Ut turpis magna, venenatis id, convallis sed, imperdiet sit amet,
  38. nisl. Curabitur ultrices dui vitae ante. Sed enim nulla, malesuada at, varius
  39. eu, tempor ut, tortor. Proin faucibus, ligula ut vulputate varius, libero tellus
  40. ultricies justo, vel pellentesque turpis orci quis dui. Cras sodales. Nam in
  41. sapien. Sed id pede. Duis ante. Duis ac lorem et arcu tempus accumsan. Aenean ut
  42. velit. Aliquam vitae velit. Cras cursus facilisis lectus. Duis nisi dui,
  43. interdum nec, euismod sed, mollis at, lacus. Praesent venenatis nibh vel mi.
  44. \end{handpar}
  46. \begin{handpar}
  47. Aliquam vestibulum bibendum lacus. Phasellus sit amet pede. Class aptent taciti
  48. sociosqu ad litora torquent per conubia nostra, per inceptos hymenaeos. Ut vitae
  49. massa. Cras sed ligula sit amet elit condimentum placerat. Nunc scelerisque
  50. mauris faucibus neque. Donec feugiat venenatis enim. Integer lacinia dolor eget
  51. velit. Aenean sit amet diam. Donec pellentesque, dui in scelerisque suscipit,
  52. velit leo ultrices tellus, sed feugiat quam diam at leo. Sed congue. Curabitur
  53. purus massa, aliquet ut, dictum a, pulvinar vel, purus. Proin arcu. Phasellus
  54. ullamcorper sapien. Vestibulum est.
  55. \end{handpar}
  57. \begin{handpar}
  58. Sed et arcu id odio varius egestas. Praesent ullamcorper erat at
  59. lacus. Pellentesque in ligula. Quisque auctor, lectus eu bibendum consectetuer,
  60. nunc odio adipiscing augue, id congue nisl augue sed pede. Donec in odio in dui
  61. placerat dignissim. Morbi sagittis imperdiet tortor. Quisque purus lorem,
  62. porttitor vel, pulvinar ut, dapibus sit amet, velit. Integer est lacus, lobortis
  63. sed, sodales ut, congue eu, pede. In et velit quis nunc dictum laoreet. Proin
  64. nec lacus ac lacus tincidunt elementum. Nulla vel ipsum. Vestibulum ante ipsum
  65. primis in faucibus orci luctus et ultrices posuere cubilia Curae; Proin felis
  66. leo, viverra nec, dapibus lobortis, tincidunt ac, nisi. Fusce vel metus. Integer
  67. sit amet tortor vitae quam gravida condimentum. Sed tincidunt pretium nisi. In
  68. hac habitasse platea dictumst. Donec sagittis mattis odio. Vestibulum
  69. arcu. Etiam porta arcu eget est.
  70. \end{handpar}
  72. \vfill
  74. \noindent $\blacksquare$
  75. \end{document}
There are no comments on this page.
Valid XHTML :: Valid CSS: :: Powered by WikkaWiki