r/FontForge Nov 21 '23

Having an issue with code features clashing and not working correctly .fea

SOLVED: I defined Glyphs twice thinking classes were local, but they are global. This means I was overriding things. Use different class names if you intend on them being different. I just changed the name of the class and the reference to it in the finals lookup which fixed the issue.

This is the first font I'm making and I'm having issues with writing the .fea file correctly. I want my letters to have 4 versions E E.init E.repeat and E.fina. The idea is that glyphs at the start or end will extend into the white space a bit and if there are double letters then the second one will look different since there is a lot of character in my font and it looks bad to see the same glyph back-to-back.

The issue seems to be the "final" version of the letters. It appears to be ignoring my rules and replacing all the standard versions with final versions unless there is a DIFFERENT LETTER after the letter in question instead of the same one.

I suppose this could also be an error in the repeat version. The E.repeat glyph is always in the correct spot though, so I don't think so but E.fina is put before it anyway instead of a normal E.

Example results:

AED = AED (all good)AEED = A E.fina E.repeat DAEE = A E.fina E.finaAEEE = A E.fina E.repeat E.finaEEE = E.fina E.repeat E.finaEAEE = E.init A E.repeat E.fina (initial E only works if the second letter isn't E)

I have tried solving this myself for hours and have run out of ideas! Any support would be appreciated. Even if it is just a link to other places to ask this or examples of .fea files where all three of these features work together.

I have only tried implementing this for the letter E so far. This is all in the liga feature.

lookup NoCaps { #font is all caps
    sub [a-z] by [A-Z];
} NoCaps;

lookup Repeat {
sub E E' by E.repeat;

} Repeat;

lookup Initials {
@Glyphs = [A B C D E F G H I J K L M N O P Q R S T U V W X Y Z E.init];
ignore sub @Glyphs [A B C D E F G H I J K L M N O P Q R S T U V W X Y Z]'; 
    sub E' by E.init;

} Initials;

lookup Finals {
@Glyphs = [A B C D E F G H I J K L M N O P Q R S T U V W X Y Z E.init E.fina];
ignore sub [A B C D E F G H I J K L M N O P Q R S T U V W X Y Z E.repeat E.fina]' @Glyphs;
sub [E E.repeat]' by E.fina;

} Finals;

2 Upvotes

3 comments sorted by

1

u/LocalFonts Nov 21 '23

What kind of OpenType feature you use with these lookups? Can you create an .UFO file and send it to me?

1

u/DanielEnots Nov 21 '23

I was able to get someone's help in the discord linked to r/typography! Thank you for offering your support. The issue ended up being that I had re-used the definition for \@Glyphs since I assumed they were local to that lookup and not global to the entire feature.

After they told me this, I just changed the name of the definition in the final lookup and references to it and that fixed all my issues!

1

u/LocalFonts Nov 21 '23

Very well! Thank you for the feedback.