UNSOLVED contextual kerning in RB, MM?



  • Hi,
    I would like to kern A space V but not A space and space A. Is there way how to do it? I know you can do it directly in OpenType. Can somehow be merged kerning feature file with a MM kerning? Or can I do it directly in RoboFont using Python? Thanks!



  • @frederik I dream of the day someone would convert fontTools feature ast objects to json and we won't use fea file anymore.


  • admin

    euhm still this should work :)

    according the ufo spec:

    Any include() statements must be relative to the UFO path, not to the features.fea file itself.

    see http://unifiedfontobject.org/versions/ufo3/features.fea/

    your includes implies the fea file is one level up from the ufo.



  • Okay I tested it outside of my font.
    in one case it worked in the other it did not.
    when using fontMake from cmd it exported correctly what couldn't be testInstalled from RoboFont. I am sending you the file

    # did not work:
    feature ss01 {
        include(../otherFea.fea);
    } ss01;
    #otherFea:
    sub A by B;
    
    # worked:
    
    include(../otherFea.fea); 
    #otherFea:
    feature ss01 {
        sub A by B;
    } ss01;
    
    

  • admin

    tested with a simple dummy font and it works fine...

    could you send me such a UFO with fea code? thanks!


  • admin

    oh that is not good... a test install should be the same as generating a binary



  • no problem, thanks for help on the way!

    I came across an issue that RoboFont doesn't want to accept include command when test installing. I test install nearly every hour, so this was pretty important for me.

    I didn't find anything out there that would flatten the files into one, so here is a small recursion

    https://gist.github.com/jansindl3r/44deab6094f7423b1b19e3cecd221f23



  • @jansindl3r that is a nice clean solution, thanks for sharing!



  • That was pretty hard to do.. sometimes I am so blind to easier solutions. This works very well!
    kern.fea generated by AFDKO
    and contextualKern.fea done by hand

    feature kern {
        include (kern.fea);
        include (contextualKern.fea);
    } kern;
    

  • admin

    That is possible with fontTools feaLib. See https://fonttools.readthedocs.io/en/latest/feaLib/



  • @gferreira thanks! I see that all the features are strings. It would be nice to have some sort of parser that creates classes or a dictionary out of it so I can just say features['kern'].append('blablabla')

    As a first prototype this works well. It's a bit clumsy though. The SpaceCenter preview doesn't preview it, but it exports correctly and FeaturePreview extension shows it correctly as well.

    import metricsMachine
    
    font = metricsMachine.CurrentFont()
    kernFea = font.kerning.compileFeatureText()
    
    closer = '} kern;'
    additions = [
        "pos V space' V -125"
        ]
    additions = [' '*4+i+';' for i in additions]
    additions = '\n'.join(additions)
    kernFea = kernFea.replace(closer, f'{additions}\n{closer}')
    font.features.text = kernFea
    


  • hello @jansindl3r,

    you could try converting the font’s kerning into kern feature code with MetricsMachine:

    import metricsMachine
    font = metricsMachine.CurrentFont()
    kernFea = font.kerning.compileFeatureText()
    

    …then add your triplets there, and add the kern feature to the font features.

    good luck! let us know if it works