Programmatically Creating a Large number of Ligature Glyphs

Get help with FontCreator here. Please do not post feature requests or bug reports here.
Post Reply
xonoa
Posts: 6
Joined: Fri Jun 09, 2023 3:50 pm

Programmatically Creating a Large number of Ligature Glyphs

Post by xonoa »

I'd like to create a large number of ligatures with a consistent naming scheme.

Is it possible to instruct FC to generate new glyphs programmatically? Ideally I'd be able to enter a pair of lists, and it would generate a glyph for each combination of names in those lists. Even better if I could have it add the contours of the composing glyphs to them. I might have upwards of 10,000 glyphs to create.

I found this topic (viewtopic.php?t=670) from 2005 that seemed to indicate that there was once some interest in a macro or scripting system for FontCreator, but I can't find any other references to it.
Bhikkhu Pesala
Top Typographer
Top Typographer
Posts: 9890
Joined: Tue Oct 29, 2002 5:28 am
Location: Seven Kings, London UK
Contact:

Re: Programmatically Creating a Large number of Ligature Glyphs

Post by Bhikkhu Pesala »

Complete Composites and Transform Scripts can be used to generate glyphs automatically from base glyphs and accents (or any combination of glyphs).

To write your own scripts to add to the existing CompositeData.xml file or to compose Transform scripts to suit your needs may take a lot of work, so it is only worthwhile if you plan to create a good number of similar fonts with the same character sets.
My FontsReviews: MainTypeFont CreatorHelpFC15 + MT12.0 @ Win 10 64-bit build 19045.2486
X0n0a
Posts: 2
Joined: Fri Nov 26, 2021 6:24 pm

Re: Programmatically Creating a Large number of Ligature Glyphs

Post by X0n0a »

Ok, I've looked through those pages, but I'm still not sure how to go about this.

I've written a Python program that adds the glyphs and renames them based on the loops, but now I need to add the component glyphs based on their names. Is there a keyboard means of adding members to a composite glyph using the member's names? If there is that I can just have python add them all 'manually'.

Is there documentation about the Transform XML that lists the possible tags? I'm not sure how I would go about writing a Transform script that adds a glyph, makes it composite, and then adds the member glyphs to it.

For completing composites: how is the CompositeData.XML used? How do we tell FC to use the .XML to create the glyphs listed within? What are the GlyphMapping tags refering to? The Per Mille shows that it's composed of two "37" members, but that's not the percent sign, so what is it?
xonoa
Posts: 6
Joined: Fri Jun 09, 2023 3:50 pm

Re: Programmatically Creating a Large number of Ligature Glyphs

Post by xonoa »

Ok, I've figured out how to do it I think using the Custom Formula button in the Edit menu. The only issue is that that button is not accessible through hotkey, just pressing down 15 times and hitting enter.

Is there a better way to accomplish that?
Bhikkhu Pesala
Top Typographer
Top Typographer
Posts: 9890
Joined: Tue Oct 29, 2002 5:28 am
Location: Seven Kings, London UK
Contact:

Re: Programmatically Creating a Large number of Ligature Glyphs

Post by Bhikkhu Pesala »

X0n0a wrote: Sun Jun 25, 2023 12:59 am For completing composites: how is the CompositeData.XML used? How do we tell FC to use the .XML to create the glyphs listed within? What are the GlyphMapping tags referring to? The Per Mille shows that it's composed of two "37" members, but that's not the percent sign, so what is it?
Select the Per Mille character, Complete Composites, CompositeData.XML
Complete Composites.png
Complete Composites.png (32.54 KiB) Viewed 5957 times
The Per Mille sign is an example of how Complete Composites can be used as a design aid. It combines two % symbols (decimal code-point 37: hold Alt type 37) to create a composite. Decompose the composites, delete the unneeded contours, and adjust spacing if necessary to make a Per Mille symbol that perfectly matches the percent sign in your font.

The transform scripts, e.g. Eastern Europe, inserts many characters, and then composes them as composite glyphs. Most can be left as composites. You can create your own Transform scripts to insert different characters.

The lack of Access Keys on several menu items is clearly an oversight.
My FontsReviews: MainTypeFont CreatorHelpFC15 + MT12.0 @ Win 10 64-bit build 19045.2486
xonoa
Posts: 6
Joined: Fri Jun 09, 2023 3:50 pm

Re: Programmatically Creating a Large number of Ligature Glyphs

Post by xonoa »

OK, I ended up using the Python method to add the glyphs 'by hand'. This will probably bite me in the butt later, but it'll work for now.

Though I've run into another issue: Theta-grek cannot be used in ligatures it seems. I believe this is due to the character being from another script than Latin.

Looking online this seems impossible to correct directly. To sidestep the issue I made a contextual alternatives feature that takes the Theta-grek character and subs it for a glyph without a code point that will stand in for Theta-grek. The issue I have now is that the calt feature is later in the OTF code than the liga and clig, so it doesn't trigger until after the liga and clig have already failed to replace things.

I've tried moving the calt up in the code, but upon exiting the code editor it moves it back to the bottom.

This thread viewtopic.php?t=4066 says that changing the order of precedence is "not difficult", but I cannot figure out how to do it. I've move the lookups themselves up in the order shown in the Open Type editor, but in the code itself it is still ordered liga, clig, calt.

How do you change the order of precedence for OTF features?


Edit: Nevermind, I figured that out, I was moving the wrong block of code. Now it's processing in the right order I think, but it's just not working. I wonder if the fact that the original character was Greek will prevent any future ligatures from working, even if the Greek character has been replaced with a Latin one.
Post Reply