Can 'calts' and positional forms have stylistic sets?

I'm working on a Latin font (in FontLab 7) with contextual alternates and positional forms (programmed in the calt feature). They're all functioning and I'm thrilled (shout out to Simon Cozens, thanks for great advice but I don't know how to proceed with programming the stylistic sets for these alternates.
The basic intention: ss01 would be super long ascenders, ss02 long ascenders with a particular type of flourish (eg swirly), ss03 a different type of flourish etc (eg fragmented).
The tricky part: getting the stylistic set substitutions to apply to the contextual alternates and positional forms.
An example of how the type currently automatically functions: betrayed by blobs is automatically substituted by: b.init e t r a y e d.fina space b.init y.fina space b.init l.calt o b s.falt
The problem: Although the mid-word b glyph is substituted when the ss01 feature is turned on (  b.ss01 ), unfortunately the b.init won't substitute to the corresponding ss01 glyph. Neither will the d.fina or l.calt.
The corresponding alternates are currently named b.init.ss01 (or b.ss01.init ). It's not great, but it's kept me organised while I've drawn them.
I hope this makes for an interesting question (I hope I've described it well enough). It'd be fantastic to hear any ideas on how to solve this coding challenge. Thank you for looking!


  • John HudsonJohn Hudson Posts: 2,832
    OpenType Layout mostly proceeds by lookup order. So you need to be aware of the glyph string content at each stage, taking the output from the previously applied lookups as input for subsequent lookups.

    So there are two ways to achieve what you want to do, depending on the order of the lookups.

    a) Process the calt substitutions first, so

    b -> b.init

    and then process the ss01 substitutions

    b -> b.ss01
    b.init -> b.init.ss01

    b) Process the sso1 substitutions first, so

    b -> b.ss01

    and then process the calt substitutions

    b -> b.init
    b -> b.ss01.init

    [It is helpful, but not necessary, to arrange the suffixes in the glyph names to remind you of the order in which you intend to process them.]

    If you substitutions are not working as intended, it is probably because the output from your first lookups is not coded as input for the second lookups.
  • Just adding to what John said: These features will be applied to sub-ranges of a string. Supposed both calt and sso1 are applied for a given sub-range of the string: then the processor will take whatever lookups are associated with either of those features and process the lookups one at a time in the order that lookups are arranged in the GSUB (or GPOS) lookup list.
  • Thanks. I tried John's suggestion in the ss01 feature
    a) Process the calt substitutions first, so

    b -> b.init

    and then process the ss01 substitutions

    b -> b.ss01
    b.init -> b.init.ss01
    but FontLab doesn't like it... When I click 'update', it just deletes the new line of coding. Have I misunderstood something?
  • Adam JagoszAdam Jagosz Posts: 688
    edited August 2021
    Are you using FontLab’s autogenerated features? These are marked with a star and can be toggled with the star button. A feature’s auto code goes between #> feature and #< feature, so you can also add manual code outside these tags.
    feature liga {
    # write custom code here
    #> feature
    sub f i by f_i;
    sub f j by f_j;
    sub f l by f_l;
    #< feature
    # or here
    } liga;
  • Thank you Adam! That solved it. Yes, I was incorrectly trying to insert the code in the middle with the other substitutions. Placing it were you indicated (in the Spoiler) solved it.
Sign In or Register to comment.