I created a Metafont font with a randomizer, such that each time I compile the font, it looks different. Using those fonts, I like to create handwritten looking parts in my document. I would like to use 10 to 20 different versions of my font, and each letter randomly chooses on of the fonts. Without the randomized fonts all the e's, for example, would look the same.

Three options how this might be possible come to my mind:

  1. Choose a font randomly for each new letter in the document.
  2. Create hundert fonts, each with only a single letter in a many variations. For each letter in the document, choose a random letter from the corresponding font.
  3. Load the fonts in turn, the first character, the first font, second character the second font... and start with the 21st character from the beginning again.

I tried to use the options above, but I wasn't competent enough to get result.I use pdfLaTex on Overleaf, but if it only works with LuaLaTeX or XeLaTex, that would be great, too.

I am German, so the letters ä, ö, ü, ß, Ä, Ö, Ü (as direct imput) and € (as \euro) should also be possible to use.


I wrote a program using the links provided in the comments. They work fine with the normal letters, but the Umlaute don't seem to work. Below a minimal working example:


\def\klein{% random non capital letter
  \foreach\x[count=\xi] in{a,...,z}{\ifnum\xi=\mytemp\x\breakforeach\fi}%

\def\gross{% random capital letter
  \foreach\x[count=\xi] in{A,...,Z}{\ifnum\xi=\mytemp\x\breakforeach\fi}%

\newfont{\fontA}{A}     % includes A a
\newfont{\fontB}{B}     % includes B b
\newfont{\fontAE}{AE}   % includes Ä ä
\newfont{\fontOE}{OE}   % includes Ö ö
\newfont{\fontUE}{UE}   % includes Ü ü
\newfont{\fontSS}{SS}   % includes ß

    \@Handschrift#1 \@empty
\def\@Handschrift#1 #2{%
   \ifx #2\@empty\else

\Buchstabe{A}{\fontA \gross}
\Buchstabe{B}{\fontB \gross}
\Buchstabe{Ä}{\fontAE \gross}
\Buchstabe{Ö}{\fontOE \gross}
\Buchstabe{Ü}{\fontUE \gross}

\Buchstabe{a}{\fontA \klein}
\Buchstabe{b}{\fontB \klein}
\Buchstabe{ä}{\fontAE \klein}
\Buchstabe{ö}{\fontOE \klein}
\Buchstabe{ü}{\fontUE \klein}
\Buchstabe{ß}{\fontSS \klein}

\Handschrift{AB ab} % works fine

\Handschrift{äöüß ÄÖÜ} % Does not work


I also tried to use "a and \"a in both \Handschrift{} and \Buchstabe{}, only with the error messages.


2 Answers 2


This selects a font at random for each letter, from a list of loaded fonts and their short names, taken from Overleaf. You would need to replace this list with your own.

The parsing method is David Carlisle's taken from this answer about making the censor package handle German characters (hence the dependency on censor, which I should be able to reduce to a dependency on ifnextok but I don't currently have time




\def\stringend{$} %repeated to avoid confusing my editor's syntax highlighting

  {\IfNextToken\@sptoken{ \bl@t{\random@Block}}%




\randomfont{This text should be in random fonts äöüß.  It's quite long and should line wrap.  I wonder what happens if it has a double blank line in it.

Let's find out whether it starts a new paragraph at the beginning of this sentence. Yes}

\randomfont{This text should be in random fonts äöüß}\par


And here's the output: output of above LaTeX code, with each character in a different font

  • With my selection of default fonts it looks rather like a ransom note; hopefully yours will sit better together. And as for the keming...
    – Chris H
    Mar 12, 2020 at 12:17
  • I use \newfont{\myfont}{myfont} to load a new font in LaTeX, but with this method I don't seem to be able to load the fonts in the randomisiere. I can only load one font in the randomizer, and then, instead of just the letter, it outputs /m/n/15 before it. And it outputs the errors: Missing \endcsname inserted. and Extra \endcsname. Do you know what I need to change?
    – Niels Wer
    Mar 13, 2020 at 10:14
  • Font packaging and loading isn't really my area of expertise, but I don't think \newfont is the way to go
    – Chris H
    Mar 13, 2020 at 11:29

Since you're using MF to generate your font, you could use TeX's native ligature/character substitution to use alternate versions of letters based on context, e.g., a different e might be used whether it follows t or h. It won't quite give you complete randomness since every instance of, e.g., te will look the same.


You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .