Do we have Conditional Ligature feature only in certain conditions???

edited August 2022 in Technique and Theory
I am looking for conditional ligature feature only in certain condition? Currently, if I do standard ligature, it will always apply to two or more glyphs whenever it see them. Once it becomes ligature, I can't do other substitutions on lig. glyphs. So I want ligature applied to certain conditions and not always. Or can dlig ( example: t s --> t_s ) be called within calt when they follow certain @LETTERS??? Any advice on this???


  • Once it becomes ligature, I can't do other substitutions on lig. glyphs.

    Well, just order your ligature LAST and then you can do any other substitution on them.

    However, if you genuinely want a conditional ligature, that already exists as 'clig'

    Tag: 'clig'

    Friendly name: Contextual Ligatures

    Registered by: Adobe

    Function: Replaces a sequence of glyphs with a single glyph which is preferred for typographic purposes. Unlike other ligature features, 'clig' specifies the context in which the ligature is recommended. This capability is important in some script designs and for swash ligatures.

  • WAY KYIWAY KYI Posts: 127
    edited August 2022
    Thank you very much Mr. Thomas Phinney. clig is under Contextual Chaining Substitution in Fontforge and I am a little lost there how to proceed, mainly I can't write t s to t_s ligature in dialogboxes. Do you have any sample how it is done within clig feature??? I can write clig, but I need to call clig into my calt feature. Is that how it is done??? Note: I could not find any written samples in the web except sample images. Is clig feature only act when it is called or it does by itself when Shaping Engine run thru the context. Here is example what I need to do:

    context: @LETTER1 t s @LETTER2
    result     @LETTER1 t_s @LETTER2
    LETTER 1&2 are required for me to do t_s lig. and all other LETTERS out of these groups, I do not want to proceed or do the ligature. I do not want ligature does it by itself without the condition that I set.

  • Ok, we need to back up a little here with some background knowledge.

    There are two different concepts here: the first is OpenType lookup types, which are kind of like virtual machine instructions. They tell the shaper what to do. For your purpose, you need a GSUB6 (chained contextual substitution) instruction. These instructions are arranged into groups called lookups.

    The second concept is a feature tag. These are simply organisational labels which arrange the lookups into groups. The shaping engine calls these lookups by tag.

    The problem is that when the OpenType spec was being written and the features were being specified, these two concepts got conflated. For example, there’s a “mkmk” feature whose name strongly suggests that you should put mark-to-mark instructions into it. But you don’t have to! You can put mark-to-mark instructions into “mark” if you want, or into “kern”, or whatever - so long as the shaper calls it in the order you expect. (As a wrinkle, older shapers did only execute certain instructions in certain appropriately named features.) Of course, as a gift to your future self you probably should put lookups in sensibly named features, but there’s nothing to stop you putting every single rule (in the appropriate order) in “rlig” and damn the torpedoes.

    But when you say “clig is under contextual chaining substitution” it sounds like fontforge is further conflating these two concepts.

    You want a GSUB6. You should probably put it in clig. But one does not equal the other.
  • John HudsonJohn Hudson Posts: 2,826
    I mostly ignore clig and just put any contextual substitutions in either calt or rlig depending on whether I want the user to be able to disable the substitution or not.
  • WAY KYIWAY KYI Posts: 127
    Thank you everyone and thank you very much Mr. Simon Cozens. I did as you suggested using Contextual Chaining Substitutions below. It is kind of working and I finally figured out how to implement in FF. Here my sample code:

    lookup pstsPostBaseSubstitutionslookup01 {
      lookupflag 0;
        sub [\uni1014 ] [\uni103E ]' [\uni102F ]'  by \uniE038;
    } pstsPostBaseSubstitutionslookup01;

    I print this out from FF as fea file. Here are some of my questions:
    Since, this is part of the psts section, the ligature won't run by itself, unless the condition I set are met, right? Can I put some classes after \uni102F?? and can I add glyphs between \uni103E and \uni102F which is not part of the source of ligature??? Like, 

    sub [\uni1014 ] [\uni103E ]' @letters [\uni102F ]'  by \uniE038; ??? Thanks
  • Simon CozensSimon Cozens Posts: 698
    edited August 2022
    • Since, this is part of the psts section, the ligature won't run by itself, unless the condition I set are met, right? 
    This doesn't depend on what feature it is in; the purpose of a contextual chaining substitution is that the substitution is done if the context matches. So it is always the case that the rule is only run when the conditions are met.
    • Can I put some classes after \uni102F?? and can I add glyphs between \uni103E and \uni102F which is not part of the source of ligature??? Like, sub [\uni1014 ] [\uni103E ]' @letters [\uni102F ]'  by \uniE038; ???
    You can certainly use classes in your contextual rules (in fact, you're doing it already - the [] brackets are creating in-line classes, even though they only have one glyph in each class). However, you cannot easily form a ligature with a part in the middle which does not take part in the ligature, at least not using the "inline lookup" syntax of AFDKO. You will need to use mark filtering sets in both the contextual rule and the lookup which it calls in order to ignore the above marks.

    Can I suggest you have a look at the feature code of Noto Sans Myanmar?
  • WAY KYIWAY KYI Posts: 127
    edited August 2022
    Thanks a lot Mr. Simon Cozens. This clear my thought a lot and I will check the font you suggested. Thanks. By the way, the code I posted is not working reliably and I don't know what is wrong. It worked in Crowbar but not in Adobe or Coreldraw ( both clig & psts ). Can the glyph be run thru two or more feature sets not just lookups??? Thanks

    Update: I just did looked at noto sans myanmar font and it was almost 700 glyphs - any combinations of Myanmar characters in there. I have a little over 200 glyphs and I can't do as they did for all combinations. It will be a headache for font designers for sure. Thank but no thanks.
Sign In or Register to comment.