# alternative to METAFONT

I'm interested in creating new character forms for computer-based calligraphy (freehand letters and kerning); strangely, such an attempt seems almost unheard of google. The closest thing might be METAFONT, but it's not really in widespread use either, and quite intimidating (I've been a LaTeX user for years, but always at the surface level). I wonder, is there a similar tool (for creating letter-like symbols from pen strokes defined mathematically) perhaps with a more modern programming framework? (thinking luatex vs tex).

Quoting Knuth's METAFONT book

"It would be nice if a system like METAFONT were to simplify the task
of type design to the point where beautiful new alphabets could be created in a
few hours. This, alas, is impossible; an enormous amount of subtlety lies behind
the seemingly simple letter shapes that we see every day, and the designers of
high-quality typefaces have done their work so well that we don’t notice the
underlying complexity."


My end-goal is (much) more ambitious: I want to create a new paradigm for graphical text representation by computers, closest as possible to human handwriting. Thus, a font format won't do, because it is too restrictive in scope (necessarily finite, frozen, discrete), where every character, ligature, should be drawn on-the-fly according to a given context.

Still, a key ingredient will always be the creation of a single character, and that's where I'm looking for the best (most versatile, fastest) existing tool. The rest is simply (!) artificial intelligence of some kind (learn how to draw and combine such letters) and a good understanding of manual calligraphy to make it look good.

Note: I provided a bit of context to explain my goal, but the question is actually about a METAFONT alternative to draw individual characters. The other part of the project is definitely too broad to discuss here.

Another note: a recent trend in AI is to mimic handwriting with some form of neural network. It's a very interesting approach, with fascinating results already, but quite orthogonal to my question. For one thing, it's not clear how glyphs generated in such a way could be integrated in a more standard text-editing workflow, but that's just a technical difficulty (and shared with any approach that's not based on existing font technologies). More limiting I think, in the long-run, is that the generating algorithm doesn't seem to have a concept of text structure, such as sentences and paragraphs, let alone meaning of the words, and "persona". Again, that could be alleviated with improving technologies. What really distinguishes the two ideas is that I'm proposing a system to simulate the physical process of putting ink on paper (or another medium), something that a glyph generated from a training set will not be able to do (notably, pen strokes that look like they could not come from physical writing should not occur).

• Is it something like the French cursive font that you want to create? This one has been actually created with METAFONT. iml.univ-mrs.fr/~beffara/soft/frcursive – Franck Pastor Jan 24 '15 at 17:54
• Sounds devilishly hard. I'm curious as to why, though: is it as an intellectual challenge or something? Whenever I've had to mark several dozen handwritten exams, I started to yearn for standardization, not hoping computers would write more like people.... – jon Jan 24 '15 at 18:12
• tex.stackexchange.com/q/29425/7883 seems relevant. – Thérèse Jan 24 '15 at 19:41
• I don't think TeX and Metafont are really the right answer here. Your Metafont programs can certainly contain random elements, but they're only random at compile time, not run-time (use-time). I suppose you could have Metafont regenerate all your characters before they're used, but this would be agonizingly slow when compiling anything but trivial documents. You might be able to draw characters in something like tikZ, with random variations, and type your texts with commands to generate them anew rather than with boring old characters, but this seems pretty klugey unless done as a one-time tri – dgoodmaniii Jan 24 '15 at 21:58
• ck. Ultimately, I think you need a different system to do what you want; but wiser heads than mine might know better. – dgoodmaniii Jan 24 '15 at 22:01

I've been thinking about this problem, and came up with a (very) beginning basic solution using lualatex and the luamplib package.

\documentclass{article}
\usepackage{luamplib}
\def\a{%
\begin{mplibcode}
beginfig(1);
fudge := normaldeviate;
fudge := normaldeviate;
w = 12pt; h = 20pt;
pickup pencircle scaled 2;
fudge := normaldeviate;
z0 = (0+fudge,2h/3+fudge);
fudge := normaldeviate;
z1 = (w/2+fudge,h+fudge);
fudge := normaldeviate;
z2 = (w+fudge,2h/3+fudge);
fudge := normaldeviate;
z3 = (w+fudge,0+fudge);
fudge := normaldeviate;
z4 = (w+fudge,h/8+fudge);
fudge := normaldeviate;
z5 = (w/3+fudge,0+fudge);
fudge := normaldeviate;
z6 = (0+fudge,h/3+fudge);
fudge := normaldeviate;
z7 = (w+fudge,h/2+fudge);
draw z0..z1..z2..z3;
draw z4..z5..z6..tension 2..z7;
endfig;
\end{mplibcode}
}
\begin{document}
\a \a \a \a
\end{document}


This defines a macro, \a, which draws a very simple lowercase "a," but does it with all the points subject to some degree of randomization (between -1 and 1 Postscript points). This solution lacks both precision and generalization, but does show that what the OP wants is possible in some form of LaTeX. One run of this document produced the following:

I defined a macro here, but it's possible (though probably rather difficult) that this might be done entirely in active characters, so that one might type simply "a a a a" rather than "\a \a \a \a". It would probably be best to limit this to an environment, though, as otherwise it would wreak havoc with your other macros. I have neither the time nor the expertise to define such an environment, but it seems to me that it would be possible.

I do hope that if you make any progress along these lines, you'll make them publicly available. I don't have the personal drive to do this myself, but I'm quite interested to see broader results.

• very nice, thank you! luatex looks quite powerful, and you show that METAPOST could be the right tool. So far I was being swayed towards postscript type 3 (dynamic fonts), with some impressive publications, but it's better to have two alternatives to explore. That being said, it's a very long-term hobby that I intend to entertain, so don't hold your breath for results! (and I know very little about all aspects). – baptiste Jan 28 '15 at 10:33

I have used Metafont to create several calligraphic fonts (bookhands on CTAN) based on writing between Roman times and the 15th century. Later I used FontForge to convert some of them to type 1 fonts, as well as adding a few tweaks like accenting some letters.

FontForge is free software with a graphical user interface rather than a textual one. I know it runs on Linux systems but don't know about the others.

• FontForge does have a Windows release and runs on Macs with XQuartz as an X11 compatibility layer. – Paul Gessler Jan 24 '15 at 17:20
• Nice work, thanks for sharing. However, I do not intend to create a font or typeface, but something new, more similar to handwriting where each and every realisation of a glyph is unique (yes, it's very ambitious). – baptiste Jan 24 '15 at 17:33
• @baptiste: And how will people be able to use that? – Reinstate Monica - M. Schröder Jan 24 '15 at 23:22
• @MartinSchröder well naturally there would have to be another program playing the role of TeX, to combine those glyphs (but with different rules, not based on historically rigid boxes, but rather on things like nib+paper+ink mechanical interaction, as well as a random component, or even taking into account "character" or emotions, e.g. the meaning of the words being written). – baptiste Jan 25 '15 at 0:01
• @baptiste: Then I suggest to investigate LuaTeX with it's built-in MetaPost; you could draw your letters on demand. – Reinstate Monica - M. Schröder Jan 25 '15 at 0:07

Iff you want your font to be widely usable (i.e. to be used by other programs than TeX), it must be an OpenType font, as that is the standard font format in use today. The best tool used to create them by the TeX community is MetaType1; I strongly suggest to contact the Poles.

And of course FontForge is an indispensable tool.

• I don't think a font is the right concept for what I have in mind. – baptiste Jan 24 '15 at 23:57