[Tex/LaTex] alternative to METAFONT

fontsmetafont

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).

Best Answer

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:

four randomized lowercase "a"

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.

Related Question