Randomized Comic Lettering Font - Code help needed

shockomotive's picture

Greetings Typohiles!

I have been lurking this forum for quite awhile and now that I have run into a serious fontmaking problem myself I could think of no better people to turn to than the Typophiles.

So here is my project: this is part of my final thesis, so I am pretty desperate in making it work. The basic idea behind it all is create a font that will—via script–generate the outlines of each glyph that is typed. So if a user were to type one line, erase it and then type the same line afterwards, the glyphs would come out completely different.

This is why the working title for this font is “Aaaargh!!”.

Unlike with Beowolf, whose PostScript method will render the changes applied to the letters only in print, this font is supposed to do it on screen. From what I have gathered so far, this is possible with OpenType-fonts as they allow the inclusion of Python scripts. These in turn can manipulate glyph outlines, positioning, etc.

I have no idea how to script Python. And while I do have some experience with actionscripting in Flash and the syntax is pretty similar, what I need here is way beyond the scope of my skills. First, let me show you what I mean to do:

Phase 1: Generating random glyph outlines by interpolation of several "Master Phases".

Fig 1: The master phases, shown with very little variance here. This will effect on the degree of "mutation" the interpolation will output. Compare Fig. 5 and 6.

Fig 2: Master phases, with more variance between the glyphs this time.

Fig 3: The master phases, overlayed. The blue areas show the boundaries of of movement the interpolation has for placing the nodes. The green areas stand for the possible positions of the handles. These polygons are created by the x/y-coordinates of the respective points in the master phases.

Fig 4: This figure demonstrates why four master phases are in use. Interpolation requires, naturally, a minimum of two phases. If more than two are used however, the degree of possible variations multiplies. This also enables a better simulation of variation within characters that ahndwriting would produce as body machanics and the flow of writing influence the appearance of characters in writing.

Fig 5: Variation is even more noticeable when more differently styled masters are used. Enjoyably, the interpolated phases are very consistent in style, so even though a degree of randomness is introduced into the character outlines, they still look like they belong together.

Fig 6: Masters and interpolated characters in a row (low variance).

Fig 7: Masters and interpolated characters in a row (high variance).

Fig 8: The introduction of two additional parameters that randomly rotate and scale one out of five characters are supposed to further simulate the changing angles of strokes in handwriting.

Phase 2: Expanding the basic lines with tools to true outlines

Fig 9: Now that the characteres base strokes are randomized, they get expanded by a "tooltip" which is a geomtrical shape–although more complex shapes would also be concievable–that is applied over the length of the path.
In this stage, the tooltip is still static, I am however considering adding another parameter to its rotation to make it react to changes in the path.

Fig 10: After the base strokes are expanded, terminators that simulate the dynamics of starting/ending a stroke and the slight bleeding that occurs when the writing tool rest on or is pulled away from a surface.
As of now, the method in creating these is rather primitve, taking the last position of the tool applied to the outline, moving a copy of this along the direction of the path, rotating an scaling it and the connect the extrema of those two shapes.
This will change though, as soon as I can find a method for doing so.

Phase 3: Altering the baseline

Fig 11: The circular movement of the wrist when writing left to right results in the lines moving slightly upward until the hand is moved to the right for an easier writing position. To encorparate this effect, the first character of the first syllable is moved slightly below the baseline and a random character between 10-15 characters to the right is chosen and has its baseline lifted. The positions of the characters in between those extrema are interpolated in non-linear fashion, resulting in a slight curvature of the baseline.
I am still working on the selection criteria, so they remain subject to change.
Still I would like the frequency and amplitude of the basline undulation to be controllable factors.

So far this is what I would like to. Which leads me to the problem of how to do it.
Is what I have cooked up here possible in Python? Has anybody tried to implement this before? Do you know of anybody who would like to collaborate in such a project or can be hired for it? Your help would be much appreciated!


Stephen Coles's picture

Sounds like a worthy project. You need to get in touch with Erik van Blokland.

Miguel Sousa's picture

> From what I have gathered so far, this is possible with OpenType-fonts as they allow the inclusion of Python scripts.

Where did you get that idea? Last time I checked, the only scripting-like ability available in OpenType is through GSUB and GPOS lookups.

shockomotive's picture

Stephen: I tried, but I can't get through to him mailwise. He is probably busy with his own work right now.

Miguel: Whew, you scared me there for a second.
If you follow this link here,

you'll arrive at the RoboFab page.

RoboFab is a little plugin that works with FontLab and allows manipulation of glyph segments via Python script. It also allows the usage of what I called "tooltips" in my descriptions, only that they are called pens, but the idea remains the same.

RoboFab saves data in its very own file format called UFO (Unified Font Object) which is pretty neat as it is XML-based and can be read without an editor. It exports fonts into every format that is supported by FontLab.

I thought that the Python scripts you write for RoboFab would somehow get included into the font file and be run when the font is in use. Maybe, this was a misunderstanding and the scripts are only executed before the font is generated and the font afterwards becomes just a normal font with all the usual limitations.

I will check on that, but this will require some time.

If in the meantime you come up with any other ideas, please let me have them.

Miguel Sousa's picture

> I thought that the Python scripts you write for RoboFab would somehow get included into the font file and be run when the font is in use.


> Maybe, this was a misunderstanding and the scripts are only executed before the font is generated and the font afterwards becomes just a normal font with all the usual limitations.

Exactly, you got it.

It's unfortunate that you've started this thread on your blog area. Have you had started it on the Build forum, and I'm sure it would have contributions from other people as the topic is very interesting. I had a hard time finding it again this time around, for example.

The moderators usually move threads to other forums if it seems appropriate, but I'm told that they can't do that with personal blog threads.

Miguel Sousa's picture

BTW, Tal Leming is another guy you should be in contact with. He's behind the OpenType magic in Ed Interlock and Local Gothic.

Stephen Coles's picture

I've promoted this to the front page. Hopefully that will drive some readers.

shockomotive's picture

Miguel: You're right, build forum sounds like the place to go. Hope nobody will mind the double post, but as I seem to have put this one into the blog category it should be legit. ^^

Here's the link: http://typophile.com/node/43634#comment-268957

I have taken a look at what Tal Leming did and that's some pretty advanced stuff, too. Might be able to use a similar system of contextual alternates and ligatures… Thanks for the hint!

editor's picture

Since RoboFab applies the Python scripts before the font is rendered, you could try a "hack" approach by using something like PHP to vary the CSS stylings of a web page. In this case, the your font would have to be installed on the reader's computer.

Otherwise, you could try using PHP to call a random image from a specified folder (a folder containing your variations of the "C" character, for example.

Although the former approach would be easier, the latter wouldn't be overwhelming -- you'd just have to specify a randomization for each character you wanted to use. It wouldn't be all that hard.

editor's picture

Any word on this?

shockomotive's picture

I have been trying to achieve something similar with flash, the only problem with this approach being that it would not result in a usable font but a tool for screen display at best.

What really vexes me most is, that even with this approach there is no possibility of making the randomness happen at runtime. I would just be retrieving images from a pre-made set. Which in a way is what I am doing right now with the flipper font.

I can post some results in a couple of days, I'm really on it now.

Thank you for your input anyways, editor.

Syndicate content Syndicate content