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:
- Choose a font randomly for each new letter in the document.
- 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.
- 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.
EDIT:
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:
\documentclass{article}
\usepackage[utf8]{inputenc}
\usepackage[ngerman]{babel}
\usepackage{datatool}
\usepackage{pgffor}
\usepackage{pgfmath}
\usepackage{pgffor}
\usepackage{pgfmath}
\def\klein{% random non capital letter
\pgfmathrandominteger{\mytemp}{1}{26}%
\foreach\x[count=\xi] in{a,...,z}{\ifnum\xi=\mytemp\x\breakforeach\fi}%
}
\def\gross{% random capital letter
\pgfmathrandominteger{\mytemp}{1}{26}%
\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 ß
\makeatletter
\newcommand{\Buchstabe}[2]{\csdef{BT#1}{{#2}}}
\newcommand{\Bs}[1]{\ifcsdef{BT\expandafter#1}{\csuse{BT#1}}{#1}}
\def\Handschrift#1{%
\@Handschrift#1 \@empty
}
\def\@Handschrift#1 #2{%
\zz{#1}\space
\ifx #2\@empty\else
\expandafter\@Handschrift
\fi
#2%
}
\def\zz#1{\def\zzsep{}\zzz#1\relax}
\def\zzz#1{\ifx\relax#1\else\Bs{#1}\expandafter\zzz\fi}
\makeatother
\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}
\begin{document}
\Handschrift{AB ab} % works fine
\Handschrift{äöüß ÄÖÜ} % Does not work
\end{document}
I also tried to use "a and \"a in both \Handschrift{} and \Buchstabe{}, only with the error messages.
