glyphr-studio / Glyphr-Studio-2

The free & open source web-based font editor, made for hobbyists and typeface design beginners.
https://www.glyphrstudio.com
143 stars 17 forks source link

Ligature priority order #191

Closed rayzchen closed 9 months ago

rayzchen commented 9 months ago

I would like to make a font with ligatures which have priority order.

For example: panpa should be comprised of the ligatures pan and pa, but pana should be comprised of the ligatures pa and na, NOT pan and a. Therefore I want na to be higher priority than pan.

mattlag commented 9 months ago

Hello!

This is not possible using OTF Ligatures... and, also, I don't think it's even needed. Ligatures are defined by a sequence of Characters, they cannot be defined by other ligatures.

So, in your case, as you type the word "panpa", you would have something like this:

If you also typed "pana" it would look like this:

Ligatures 1,2,3,4 will all have a new character defined and will have their own set of unique character sequences to define them. The Visual Design (what shapes exist) for each Ligature can be whatever you want. For example, if you want pa to look like p+a, then that is fine. If you want pa to look totally new and different and unrelated to any other character, that is also fine. There is no limitation on the design of Ligature characters needing to look a certain way.

Many times, a Ligature for a sequence of character resembles the individual characters in some way. In Glyphr Studio you can use the "Copy Shapes" action, which lets you copy all the shapes from one glyph to another. Or you could use Components to make a link between Glyphs. These could help you get started - but again, the design of your Ligature is up to you, it doesn't have to look like the source characters that define it.

Let me know if you have any questions - I am going to mark this as closed because, like I said at the top, this isn't possible to achieve.

rayzchen commented 9 months ago

How can I make a font such that when I type the word panpa, I get the two ligatures pan and pa, and when I type the word pana, I get the two ligatures pa and na?

mattlag commented 9 months ago

Oh, I see your problem. There is no simple way to do that. If you define pan it will always replace the sequence p a n. The OTF file has no way of knowing what you "want" in different situations. It can only read sequences of characters.

One of the more "advanced" solutions is to use a character called the "Combining grapheme joiner". It is a zero-width character with no shapes, and it's only purpose is to split two characters that would otherwise be combined: https://en.wikipedia.org/wiki/Combining_grapheme_joiner

So if you wanted to type the word "pana" and get pa na, you would actually have to type "pa|na" (here I'm using the | character to represent the combining grapheme joiner)

The combining grapheme joiner has the Unicode id of U+034F is in between these two quotes: "͏͏"

If you are creating your own language, you can do something similar with an unused and more common character. For example, if your alphabet did not include the use of a quote, you could define ligatures for pa', na, and pana and then when you type you could just do "panpa" which would resolve to pan pa and if you type "pa'na" it would resolve to pa' and na. In this case, you could just design pa' to look like pa, and use the quote to resolve the ligature conflict, while ignoring it visually. The quote character in this example could literally be any character, but hopefully one you are not already using.

I better understand your need now, thanks for explaining it. But, font files don't order their ligature definitions, they just look for sequences starting with longest ones first.

rayzchen commented 9 months ago

Ah, alright, thanks!