googlefonts / glyphsLib

A bridge from Glyphs source files (.glyphs) to UFOs
Apache License 2.0
178 stars 51 forks source link

Problem with calt feature, wrong with fontmake, correct with Glyphs #945

Closed RosaWagner closed 9 months ago

RosaWagner commented 9 months ago

source are in this branch: https://github.com/RosaWagner/Borel/tree/vietnamese/Borel/sources

The calt feature seems broken for some glyphs only when exporting with fontmake. I don't think my calt feature is wrong since GlyphsApp compiles it correctly. It seems to affect only the glyphs with multiple top accents (which are also the last ones that I added).

cc @simoncozens @schriftgestalt

Building with GlyphsApp:

Screenshot 2023-09-15 at 18 38 13

Building with Fontmake:

Screenshot 2023-09-15 at 18 37 43

The calt feature:

# All base lowercases letters (has unicode + idotaccent), would like to use a token but 
that one is not supported by GliphsLib

@Medial=[a aacute abreve abreveacute abrevedotbelow abrevegrave 
abrevehookabove abrevetilde acircumflex acircumflexacute 
acircumflexdotbelow acircumflexgrave acircumflexhookabove acircumflextilde 
adieresis adotbelow agrave ahookabove atilde ae b c ccedilla d dcroat e eacute 
ecircumflex ecircumflexacute ecircumflexdotbelow ecircumflexgrave 
ecircumflexhookabove ecircumflextilde edieresis edotbelow egrave 
ehookabove etilde f g gbreve h i idotless iacute icircumflex idieresis idotaccent 
idotbelow igrave ihookabove itilde j jdotless k l m n ntilde o oacute ocircumflex 
ocircumflexacute ocircumflexdotbelow ocircumflexgrave ocircumflexhookabove 
ocircumflextilde odieresis odotbelow ograve ohookabove ohorn ohornacute 
ohorndotbelow ohorngrave ohornhookabove ohorntilde otilde oe p q r s 
scedilla germandbls t u uacute ucircumflex udieresis udotbelow ugrave 
uhookabove uhorn uhornacute uhorndotbelow uhorngrave uhornhookabove 
uhorntilde utilde v w x y yacute ydotbelow ygrave yhookabove ytilde z]; 

@Isolated=[$[name endswith ".isol"]];

@Initial=[$[name endswith ".init"]];

@Final=[$[name endswith ".fina"]];

# Letters that need a long connection on the base line
@Base=[e $[name beginswith "e."] $[name beginswith "eacute"] $[name beginswith "ecircumflex"] 
$[name beginswith "edieresis"] $[name beginswith "edotbelow"] $[name beginswith "egrave"] 
$[name beginswith "ehookabove"] $[name beginswith "etilde"] oe $[name beginswith "oe."] 
ae $[name beginswith "ae."] c $[name beginswith "c."] $[name beginswith "ccedilla"] 
l $[name beginswith "l."] s $[name beginswith "s."] $[name beginswith "scedilla"] 
$[name beginswith "germandbls"] x $[name beginswith "x."]];

@BaseMedial=[$[name endswith ".medi.cv01"]];

@BaseFinal=[$[name endswith ".fina.cv01"]];

# Letters that needs connection from the top
@Top=[b $[name beginswith "b."] o $[name beginswith "o."] $[name beginswith "oacute"] 
$[name beginswith "ocircumflex"] $[name beginswith "odieresis"] $[name beginswith "odotbelow"] 
$[name beginswith "ograve"] $[name beginswith "ohookabove"] $[name beginswith "ohorn"] 
$[name beginswith "otilde"] v $[name beginswith "v."] w $[name beginswith "w."]];

@TopMedial=[$[name endswith ".medi.cv02"]];

@TopFinal=[$[name endswith ".fina.cv02"]];

# Letters that needs connection from the bottom
@Bottom=[j $[name beginswith "j."] $[name beginswith "jdotless"] g $[name beginswith "g."] 
$[name beginswith "gbreve"] q $[name beginswith "q."] y $[name beginswith "y."] 
$[name beginswith "yacute"] $[name beginswith "ydotbelow"] $[name beginswith "ygrave"] 
$[name beginswith "yhookabove"] $[name beginswith "ytilde"] z $[name beginswith "z."]];

@BottomMedial=[$[name endswith ".medi.cv03"]];

@BottomFinal=[$[name endswith ".fina.cv03"]];

lookup ISOLATED {
    lookupflag IgnoreMarks;
    ignore sub @Medial' @Lowercase, @Lowercase @Medial';
    sub @Medial' by @Isolated;
} ISOLATED;

lookup INITIAL {
    lookupflag IgnoreMarks;
    ignore sub @Lowercase @Medial';
    sub @Medial' by @Initial;
} INITIAL;

lookup FINAL {
    lookupflag IgnoreMarks;
    ignore sub @Medial' @Lowercase;
    sub @Base @Medial' by @BaseFinal;
    sub @Top @Medial' by @TopFinal;
    sub @Bottom @Medial' by @BottomFinal;
    sub @Medial' by @Final;
} FINAL;    

lookup MEDIAL {
    lookupflag IgnoreMarks;
    sub @Base @Medial' by @BaseMedial;
    sub @Top @Medial' by @TopMedial;
    sub @Bottom @Medial' by @BottomMedial;
} MEDIAL;
schriftgestalt commented 9 months ago

can you compare the GDEF mark class of the two fonts? it seems to happen when there are two marks on top, maybe the font uses a alternate mark and those are defined as mark in GDEF?

RosaWagner commented 9 months ago

the Glyphs' GDEF has a less lines but nothing worrisome and the MarkGlyphSetsDef is the same in both files.

RosaWagner commented 9 months ago

precision:

khaledhosny commented 9 months ago

Where are you testing this? Do you get the issue in a specific app? You can try to debug the failing sequences with https://www.corvelsoftware.co.uk/crowbar/ and see what it does with the two fonts.

anthrotype commented 9 months ago

different GDEF GlyphClassDefs groups (specifically the one that defines mark glyphs) may be the culprit, the lookupflag IgnoreMarks uses those to decide whether to skip over the intervening mark glyphs and apply the substitutions as if the marks weren't there; if not ignored, an intervening glyph may break the substitution.

Have you dumped the --debug-feature-file <file> to inspect the features (including autogenerated ones) that fontmake compiles?

RosaWagner commented 9 months ago

Thanks for helping.

@khaledhosny I have this issue in Indesign, but the same is happening in Crowbar. I see that the feature is not applied the same way, but my understanding stops there. @anthrotype gonna try that now

The 2 files are there: Borel.zip

RosaWagner commented 9 months ago

Have you dumped the --debug-feature-file to inspect the features (including autogenerated ones) that fontmake compiles?

@anthrotype either i am using the command in the wrong way or it doesn't find anything problematic. I have the lookupflag IgnoreMarks, you say it is ignoring only one mark and not 2?

anthrotype commented 9 months ago

either i am using the command in the wrong way...

did you see a new debug feature file generated at the desired path?

The lookupflag IgnoreMarks is fine, I was trying to say the definition of what glyph is or is not a mark comes from the GDEF GlyphCassDefs, which defines four groups, in this order: base, ligature, marks and (ligature) components. I think you want to make sure that the third group that pertains to mark glyphs is identical in both the Glyphs.app generated features and in fontmake's (i.e. no glyph that is defined as "mark" by Glyphs is not also defined as such by fontmake).

Then you may want to make sure that the feature tokens as expanded by glyphsLib are the same as those from Glyphs.app, I think you should be able to inspect the latter's feature file in the ~/Application Support/Glyphs/Temp directory if I remember correctly (cc @schriftgestalt).

RosaWagner commented 9 months ago

did you see a new debug feature file generated at the desired path? It was empty but now it is working somehow. markClass has the same number of lines.

Funnily enough, adding sub acircumflexacute by a circumflexcomb_acutecomb; in the ccmp feature fixes the issue on the web, but not in Indesign.

schriftgestalt commented 9 months ago

indesign doesn't do one to many substitutions in the default composer. In the paragraph settings, you can switch to the "World Ready composer". Then that sub will work.

But that this works may point to the actual problem. Is there acircumflexacute medi or final alternate?

RosaWagner commented 9 months ago

@schriftgestalt yep, there is the same number of alternates for each letters

RosaWagner commented 9 months ago

But not only the double accented letters are affected; also letters with horn, hookabovecomb, etilde, itilde, dcroat.

Do we agree that there is a bug somewhere in glyphslib/fontmake that needs to get fixed?

khaledhosny commented 9 months ago

Your automatic classes are outdated, you seem to have added new glyph but did not update the classes. For some reason Glyphs is updated them automatically (though I don’t see Update Features custom parameter in the font). If you update them, the fontmake-built font will be fine.

RosaWagner commented 9 months ago

I update and compile everytime :/ (like a thousand times)

khaledhosny commented 9 months ago

I downloaded the glyphs file, built with fontmake and got a broken font, updated and built again and the font is working:

image
RosaWagner commented 9 months ago

@khaledhosny I updated the classes manually and it works, thanks. @schriftgestalt the update button doesn't update the "automatic" classes (with the last cutting edge version). Closing this issue and opening one in GlyphsApp's forum.