Large fonts: thoughts and a couple of wishes

Post Reply
psb1558
Posts: 5
Joined: 28 Jun 2022

Large fonts: thoughts and a couple of wishes

Post by psb1558 »

So far I've used Kern On for two fonts. I'm getting used to its ways, and I've got to say I really love it. One font has seven masters and 1368 glyphs, while the other has six masters and 4865 glyphs.

With the first, when KO runs, it finishes in under an hour. With the second, well, I started it before nine o'clock this morning, and now it's after seven in the evening and it's still running. So ten+ hours so far, the progress bar is very near the end, and I *think* the program is maybe still doing useful work (Activity Monitor says its using CPU), but I have no idea how long it's going to run. The progress bar has been near the end for a very long time. Its progress, for the last four hours or so, has been invisible.

With the larger font, I have marked 2556 glyphs "no kerning," but it's hard to tell whether or not this has helped. Many of the 2556 may be glyphs that KO wasn't going to kern anyway.

The place where KO slows down dramatically is with "Generating class kerning." The rest takes no more than an hour, probably less. I can only guess what's going on under the hood when KO is "Generating class kerning"—pretty sophisticated stuff, I bet, like comparisons of outline shapes. I have no idea whether it's even possible to find optimizations that would speed this part up.

But it's interesting to me that the extra time KO takes to kern the larger font is way out of proportion to the extra size. The relationship between size of font and time needed to run KO seems not to be linear.

The point I'm coming to here is that, if I could choose one area to concentrate on for future development, it would be optimization, especially of "Generating class kerning."

Another really useful, and I hope simple, enhancement would be the ability to skip "Generating class kerning" altogether so that we could generate fonts (with flat kerning tables) relatively quickly for testing and refinement and save the generation of classes for nearer the end of the process (maybe as an operation that could be run by itself).

I would also find it useful to be able to make KO ignore a master entirely. For a "Grade" master, for example, the kerning has to be an exact copy of that of the main master, so the simplest thing is to copy it with a script after running KO. There's no reason for KO to generate kerns for such a master.

I've just stopped KO after letting it run for ten and a half hours. The troublesome font is at https://github.com/psb1558/Junicode-font (the one that wouldn't finish in 10.5 hours is the italic; the roman works if I let KO run overnight—maybe because roman outlines are simpler?).
psb1558
Posts: 5
Joined: 28 Jun 2022

Re: Large fonts: thoughts and a couple of wishes

Post by psb1558 »

I marked about 750 more glyphs "no kerning" and succeeded in running KO overnight.
User avatar
Tim Ahrens
Site Admin
Posts: 284
Joined: 11 Jul 2019

Re: Large fonts: thoughts and a couple of wishes

Post by Tim Ahrens »

Sorry this is taking longer than would be convenient. I will have a look at your file and see whether it can be improved.

You are right, the time it takes to calculate the kerning and the class generation is non-linear. The number of pairs to autokern is roughly proportional to the square of the number of kerned glyphs (imagine every possible combination was autokerned, then it would be exactly square). With class generation, it is a similar case: Determining which classes are best to be merged requires to simulate the possible mergers. Again, this is roughly proportional to the square of classes (and, therefore, glyphs). I may be able to detect particular bottlenecks now that I have a large example font, though.
psb1558 wrote: 17 Aug 2022 Another really useful, and I hope simple, enhancement would be the ability to skip "Generating class kerning" altogether so that we could generate fonts (with flat kerning tables) relatively quickly for testing and refinement and save the generation of classes for nearer the end of the process (maybe as an operation that could be run by itself).
You can deactivate class kerning by specifying 0kB. Sorry, this is not properly documented (it’s fairly recent feature, btw).
psb1558 wrote: 17 Aug 2022 I would also find it useful to be able to make KO ignore a master entirely. For a "Grade" master, for example, the kerning has to be an exact copy of that of the main master, so the simplest thing is to copy it with a script after running KO. There's no reason for KO to generate kerns for such a master.
If you specify “Link Metrics With...” as a custom parameter for that master then Kern On will re-use the kerning of the “master master”. (Oops, I just noticed this feature has a bug in it. Will fix it).

I suppose “Link Metrics With...” would work the case of grades? I can imagine that there may be cases where you don’t want exactly the same metrics but share the same kerning between to masters, though. Maybe I should add a feature to set that explicitly.
psb1558
Posts: 5
Joined: 28 Jun 2022

Re: Large fonts: thoughts and a couple of wishes

Post by psb1558 »

Thanks for the detailed reply, Tim. I figured the explanation would be something like what you've said. I hope having my big Junicode files will help you find solutions.

It may be that there are better ways of coping than what I've done (marking big blocks of glyphs "no kerning," so that, for example, I'm now not kerning Greek at all). I'll experiment and report anything I find that helps.

Of course, the value of a tool like Kern On goes up tremendously as the size of a font increases (since it's almost impossible to kern a big font manually). So I'm very interested in getting this working.
Post Reply