Handling Large Set of Custom-Named Alternate Glyphs

Post Reply
klb
Posts: 5
Joined: 29 Sep 2022

Handling Large Set of Custom-Named Alternate Glyphs

Post by klb »

Hi Tim!

Thank you for your time and effort in creating KO! I’ve been waiting for a tool like this, and it works well.

I couldn’t find this answer on the forum yet, but I’m working with a font of ~5000 alphanumeric glyphs, all with custom names like ‘A.custom_string’ or ‘A.another_custom_string’ etc. These custom names are important to the font as they store information about how each glyph was sourced, so I need to keep these custom names.

Unless I add each custom glyph name to an OpenType Feature (i.e. Character Variant 1 ‘cv01’), I am not able to get KO to find kerning pairs for the letter, and even when I do add all the glyphs to these Features ‘cv01’-‘cv99’, I am not seeing pairs between all the letters. All glyphs are equally as likely to be chosen in my font, so I need ‘A.custom_string’ to be kerned with all another 4,999 glyphs in the font, etc.

I don’t mind waiting a couple days for the results of KO as I know this will take a while for the program to run, but I just need to know how to ask KO to the kern *all* pairs of *all* ~5000 glyphs.

Thanks in advance for the assistance! If need be, I can send along my font in a week if you can provide your preferred email.

All my best,
k
User avatar
Tim Ahrens
Site Admin
Posts: 407
Joined: 11 Jul 2019

Re: Handling Large Set of Custom-Named Alternate Glyphs

Post by Tim Ahrens »

Interesting question. All possible combinations for 5000 glyphs is 25 million pairs. Not sure whether the system will cope with this but let’s try our luck.

My first try would be working with user-set autopairs. As you may know, you can explicitly switch an ignored pair (i.e. without any of the Model/Auto/Ind buttons active) to auto by simply pressing the Auto button. What we need is 25 M user-set autopairs. The easiest way to set them is by editing the .glyphs file in a text editor (I personally prefer BBEdit for this kind of task). After you have set a user-set autopair using the Auto button you will find something like this in the .glyphs file:

Code: Select all

KernOnUserSetAutopairs = (
"A.custom_string B.custom_string"
);
Next, I’d try to insert all 25 M pairs into the file, like this:

Code: Select all

KernOnUserSetAutopairs = (
"A.custom_string B.custom_string",
"A.custom_string C.custom_string",
"A.custom_string D.custom_string",
"A.custom_string E.custom_string",
...
);
This text can be generated automatically using a simple python script (let me know if you need help with that).

If the system is not overwhelmed by the number of pairs then this should work. Maybe you should first try whether this set-up works correctly using only 50 glyphs (2500 pairs). If this works but fails with the full set then we know the problem must be the sheer number of pairs.
Eben Sorkin
Posts: 38
Joined: 27 Apr 2021

Re: Handling Large Set of Custom-Named Alternate Glyphs

Post by Eben Sorkin »

To scale back from 25 Million pairs perhaps after a kern-on process some groups of glyphs could be forced to share a logical set of kerning groups?

To what extent does Kern on do this already if you have set autopairs or are autopairs excluded from Groups?

I have thought it might be nice to be able to force/tell kern on what glyphs should share kerning groups ahead of time but get that might be just as much work to make ( or more ) than making kern on in the first place.
klb
Posts: 5
Joined: 29 Sep 2022

Re: Handling Large Set of Custom-Named Alternate Glyphs

Post by klb »

Thanks for the quick reply, Tim! I'll try this out next week and report back how the test with 50 glyphs goes.
User avatar
Tim Ahrens
Site Admin
Posts: 407
Joined: 11 Jul 2019

Re: Handling Large Set of Custom-Named Alternate Glyphs

Post by Tim Ahrens »

Regarding user-set classes, this has come up every so often. I See the other thread for my answer: /viewtopic.php?p=1269#p1269
klb
Posts: 5
Joined: 29 Sep 2022

Re: Handling Large Set of Custom-Named Alternate Glyphs

Post by klb »

To update here, I've been able to add the ~23M pairs in the fontinfo.plist file in my font's .glyphspackage folder after 2 days of my computer chugging along! Kern On seems to have worked great!

My next issue is how to export this 2.15 GB .glyphspackage file into a .ttf format without Glyphs needing to be paused for being outside of application memory during font export – using ~101 GB of RAM. I haven't yet found the solution to that, but that seems like more of a Glyphs forum question. Thanks for helping me out here! 
User avatar
Tim Ahrens
Site Admin
Posts: 407
Joined: 11 Jul 2019

Re: Handling Large Set of Custom-Named Alternate Glyphs

Post by Tim Ahrens »

I don’t think exporting a font with 23M kerning pairs is feasible with current technology.

It’s interesting to see how hardware and software continues to becomes more powerful and users still push the boundaries, I guess they always will. If, in 20 years time, producing a font with 5000 glyphs and 23M kerning pairs will be feasible I’m sure people will come up with other ideas for things that will still not be possible then.

So, it seems technology is not ready for your project yet. You will need to adjust your concept to get it to work with the current restraints. But, hey, working with limitations and trying to overcome them can be fun and lead to fascinating results!
User avatar
Tim Ahrens
Site Admin
Posts: 407
Joined: 11 Jul 2019

Re: Handling Large Set of Custom-Named Alternate Glyphs

Post by Tim Ahrens »

Also, it would be good to know or see more about your project. Maybe this is in fact an XY problem? There might be a better solution than creating 23M kerning pairs but it’s difficult to say without knowing enough details about the project. I suppose it is some kind of experiment or art project?
User avatar
Georg Seifert
Posts: 6
Joined: 29 Jul 2019

Re: Handling Large Set of Custom-Named Alternate Glyphs

Post by Georg Seifert »

Exporting the font as is, is not only a performance problem in Glyphs but there is no way to fit 15.000.000 kerning pairs into one OpenType font. The format doesn’t allow it.

So it needs some preprocessing. Meaning removing all glyphs and kerning pairs that you don’t need. Then the export should work.

I just tied and this works:
- Set all glyphs but the default ones to not export.
- Export the font (takes ~18s for me).
- if you like to use different glyphs, for each set add an instance in Font Info > Exports.
- add a custom parameter "Rename Glyphs" and add entires for each glyphs that you like to change: `A.yxz=A`. This switch the two glyphs and the other one will end up in the font.
klb
Posts: 5
Joined: 29 Sep 2022

Re: Handling Large Set of Custom-Named Alternate Glyphs

Post by klb »

Thank you, Tim and Georg, for your thoughts here. You both have been helpful in helping me step forward with my project. To answer your question, Tim, I'm working on an experimental font project where the glyphs themselves are not too complex but represent a collection of found alphabetic glyphs, and I want to be able to pick alternate characters randomly and switch out what glyphs are used as the 'A', 'B', etc.

I'm now working around the high kerning volume of ~23 M pairs by picking a handful of key kerning pairs that are essential to my project and which spell out a specific logotype, kerning all alternates which match. For example, I only make user-set autopairs for 'GL', 'LY', 'YP', 'PH', and 'HS'. With this approach, I end up working with ~650,000 kerning pairs in my final Glyphs project using Extension Kerning, and I've been able to export to the OpenType format in ~20 minutes.

I couldn't find documentation online, but I was wondering if either of you knew the rough upper limit of how many kerning pairs the OpenType kerning table should roughly accept?
Last edited by klb on 19 Oct 2022, edited 1 time in total.
User avatar
Tim Ahrens
Site Admin
Posts: 407
Joined: 11 Jul 2019

Re: Handling Large Set of Custom-Named Alternate Glyphs

Post by Tim Ahrens »

klb wrote: 19 Oct 2022 I couldn't find documentation online, but I was wondering if either of you knew the rough upper limit of how many kerning pairs the OpenType kerning table should roughly accept?
The limit is 64 kB unless you use Extension Kerning. It’s not possible to give a number of pairs: Each class-class pair does not occupy any space of its own, you have to “pay” for the whole subtable in advance and then you get the class-class pairs for free. In other words: Deleting a number of class-class pairs may not reduce the amount of necessary space whatsoever, except if this deletes the last occupied cell in a row or column of the subtable.

So, in Kern On, just set the limit to 64 kB and the TTF/OTF export from Glyphs should work fine.
klb
Posts: 5
Joined: 29 Sep 2022

Re: Handling Large Set of Custom-Named Alternate Glyphs

Post by klb »

Got it, thanks for all the information!
Post Reply