Reverse chained contextual substitution?

Simon CozensSimon Cozens Posts: 379
edited December 2019 in Font Technology
Has anyone ever implemented GSUB type 8 lookups? Yannis Haralambous' book tells me that it was specifically designed for Urdu but I'm not sure I believe him, and I don't know of any Urdu fonts that use it. Does any font editing software even support it? (FontForge apparently crashes when it sees one.) The only examples of it I've found on github are AFDKO test files.

More to the point, can't reverse contextual substitutions always be rewritten in terms of forward contextual substitutions? What is the difference between

rsub foo wibble' by wibble.alt;

and

sub wibble' foo by wibble.alt;

Comments

  • FontCreator supports it.



    More to the point, can't reverse contextual substitutions always be rewritten in terms of forward contextual substitutions?
    No.

  • André G. IsaakAndré G. Isaak Posts: 442
    edited December 2019

    More to the point, can't reverse contextual substitutions always be rewritten in terms of forward contextual substitutions? What is the difference between

    No. One area where rsub would be particularly beneficial for latin fonts would be the handling of fractions. The method developed by Tai Leming which seems to have become common necessarily imposes an upper limit on the lengths of numerators.

    http://opentypecookbook.com/common-techniques.html

    If the contextual substitutions involved could be performed from right to left using rsub, this limit would go away (not to mention the fact that the code would be much shorter and simpler).

    Unfortunately, rsub isn't widely supported so this solution wouldn't work in most applications which is why it isn't normally done.
  • Simon CozensSimon Cozens Posts: 379
    edited December 2019
    If the contextual substitutions involved could be performed from right to left using rsub, this limit would go away (not to mention the fact that the code would be much shorter and simpler).
    I think I am starting to understand - because applying the substitution in reverse allows you to "collect" results from previous (or indeed "future") lookups. So you would rewrite the code as

    rsub @figures' fraction by @figuresNumerator;
    rsub @figures' @figuresNumerator by @figuresNumerator;

    (and indeed that seems to work nicely in my tests.)
    Unfortunately, rsub isn't widely supported so this solution wouldn't work in most applications which is why it isn't normally done.

    Looks like it works on CoreText and Harfbuzz based applications, but not Adobe Illustrator (CS6 at least). I have not tested with Uniscribe.

  • John HudsonJohn Hudson Posts: 1,693
    Yannis Haralambous' book tells me that it was specifically designed for Urdu but I'm not sure I believe him, and I don't know of any Urdu fonts that use it.

    Not Urdu per se, but nastaliq style Arabic as favoured for Urdu. Nastaliq is distinctive in that the form a letter takes is determined by the final letter in a connected group, i.e. you need to know what the final letter is in order to work backwards through the joining forms. This is because nastaliq employs variations in letter weight as well as shape in the pattern of letter groups. GSUB lookup type 8 was invented to provide a means to do contextual substitutions that would be processed backwards from the end of a glyph run.
Sign In or Register to comment.