Author Topic: FEA 2.5 vs. 1.6: "languagesystem" and "script DFLT" issues  (Read 18642 times)

Adam Twardoch (FontLab)

  • Product and marketing manager, Fontlab Ltd.
  • Administrator
  • Hero Member
  • *****
  • Posts: 563
  • FontLab Studio 5.1.2, Mac OS X 10.6.8
    • FontLab
FontLab Studio uses the Adobe FDK for OpenType (AFDKO) library to compile OpenType Layout feature definitions. AFDKO uses the FEA syntax to define the feature definitions, and so does FLS (in the OpenType panel).

FLS 5.1 uses the FEA 2.5 version of the syntax while FLS 5.0.x used the FEA 1.6 version. There are some differences between those versions.

UPDATED! The problem described below only occurs in FLS 5.1 build 4311 or newer when you open older .vfb fonts which were saved in FLS 5.0.x and probably use FEA 1.6. When opening existing .otf or .ttf font, FLS 5.1 (build 4311 or newer) will decompile the feature definitions into FEA that is largely* compatible with version 2.5 required by the AFDKO 2.5 library.

*) Note: The feature decompilation in FLS 5.1 build 4311 automatically includes the "languagesystem" declarations and correctly orders them as well as the "script" declarations inside the feature definitions if the "DFLT" script is used in the font. However, certain OpenType lookup types such as GPOS lookups used for "mark" or "mkmk" are still not decompiled correctly.

If you are opening an older .vfb file (created in FLS 5.0.x), your syntax in the OpenType panel is probably still FEA 1.6. To upgrade it to FEA 2.5, you can use the free "Upgrade FEA" Python macro, or you can fix your code manually by following the guidelines below:

If you decided to upgrade your FEA code to version 2.5 manually, or if you're developing a new font, please observe the following guidelines.

** FEA upgrade step 1: Required "languagesystem" statements

In addition to the feature descriptions in the OpenType panel, in FLS 5.1 you must include a list of all languagesystems that your features are using. You should enter this list in the lower-right portion of the OpenType panel.

For a typical Latin-based font, your lower-right portion of the OpenType panel should say:
Code: [Select]
languagesystem DFLT dflt;
languagesystem latn dflt;

If you have any language-dependent substitutions, e.g. the "locl" feature for Romanian (dealing with the cedilla/commaaccent glyphs) or Turkish and Azeri (dealing with the i glyph if your font has small caps), then you should have:
Code: [Select]
languagesystem DFLT dflt;
languagesystem latn dflt;
languagesystem latn TRK;
languagesystem latn AZE;
languagesystem latn ROM;

and if you also have Cyrillic and Greek glyphs in your font, plus perhaps special Serbian variants for italic, then your lower-right portion of the OpenType panel would look like this:
Code: [Select]
languagesystem DFLT dflt;
languagesystem latn dflt;
languagesystem latn TRK;
languagesystem latn AZE;
languagesystem latn ROM;
languagesystem cyrl dflt;
languagesystem cyrl SRB;
languagesystem grek dflt;

This list of languagesystem defines, into which language systems all of your OpenType Layout features will be assigned (for example "smcp" or "onum" or "liga" or "sups"). The languagesystem list was optional in FEA 1.6 (FLS 5.0) but is mandatory in FEA 2.5 (FLS 5.1). If some of your feature definitions have special language-dependent rules (typically: "locl"), then in that feature, you'll need to enumerate all the languagesystems once again, but using "script" and "language" statements. For more information, please refer to these Typophile threads (each link will open in a new tab): [ 1 | 2 | 3 | 4 | 5 ]

** FEA upgrade step 1: "DFLT" script

In the FEA syntax used in FLS, the user can omit the "script" statement at the beginning of the feature definition. FEA 1.6 (FLS 5.0) used to always assume that in such case, "latn" OpenType script was implicitly declared. FEA 2.5 (FLS 5.1) changed this behavior. If the font declares the use of the "DFLT" OpenType script anywhere in the code, FEA 2.5 assumes that the "DFLT" script was implicitly declared, so "latn" needs to be declared explicitly. Only if "DFLT" is not declared, FEA 2.5 assumes that "latn" is declared implicitly.

When opening existing .otf or .ttf font, FLS 5.1 build 4311 will decompile the feature definitions into the FEA 2.5 syntax. But if you are opening an older .vfb file (created in FLS 5.0.x), your syntax in the OpenType panel is probably still FEA 1.6.

For example, in FEA 1.6, the "case" feature could like the following (the potentially problematic portions have been emphasized using "### NOTE THIS"):
Code: [Select]
feature case { # Case-Sensitive Forms
# Latin (empty line) ### NOTE THIS
lookup case0 {
    pos @case1 <0 40 0 0>;
    pos at <0 100 0 0>;
    pos [exclamdown questiondown] <0 190 0 0>;
} case0;
lookup case41 {
    sub hyphen by hyphen.case;
} case41;
 script latn; language AZE ; # Azeri
 script latn; language TRK ; # Turkish
 script latn; language MOL ; # Moldavian
 script latn; language ROM ; # Romanian
 script latn; language CRT ; # Crimean Tatar
script DFLT; ### NOTE THIS
lookup case0;
lookup case41;
} case;

FEA 2.5 assumes that "DFLT" is the script for which the lookups are defined implicitly at the beginning of the feature definition, so when it hits the "script DFLT;" line, it reports "DFLT has already been defined".

In such case, you should revise your code as follows:
Code: [Select]
feature case { # Case-Sensitive Forms
script DFLT; # Default ### NOTE THIS
lookup case0 {
    pos @case1 <0 40 0 0>;
    pos at <0 100 0 0>;
    pos [exclamdown questiondown] <0 190 0 0>;
} case0;
lookup case41 {
    sub hyphen by hyphen.case;
} case41;
script latn; # Latin ### NOTE THIS
 script latn; language AZE ; # Azeri
 script latn; language TRK ; # Turkish
 script latn; language MOL ; # Moldavian
 script latn; language ROM ; # Romanian
 script latn; language CRT ; # Crimean Tatar
lookup case0;
lookup case41;
} case;

Note that we moved the "script DFLT;" line to the top and then added an explicit "script latn;" before the language-specific declarations.

Another correct version of the code would be:
Code: [Select]
feature case { # Case-Sensitive Forms
# Default (empty line) ### NOTE THIS
lookup case0 {
    pos @case1 <0 40 0 0>;
    pos at <0 100 0 0>;
    pos [exclamdown questiondown] <0 190 0 0>;
} case0;
lookup case41 {
    sub hyphen by hyphen.case;
} case41;
script latn; # Latin ### NOTE THIS
 script latn; language AZE ; # Azeri
 script latn; language TRK ; # Turkish
 script latn; language MOL ; # Moldavian
 script latn; language ROM ; # Romanian
 script latn; language CRT ; # Crimean Tatar
lookup case0;
lookup case41;
} case;

Note that we removed the "script DFLT;" line at the top, because that's the one that is implicitly assumed. We still needed to add an explicit "script latn;" before the language-specific declarations.

However, since FEA 2.5 requires us to list the "languagesystem" statements in the lower-right portion of the OpenType panel, which in this case would be:
Code: [Select]
languagesystem DFLT dflt; # Default
languagesystem latn dflt; # Latin
languagesystem latn AZE ; # Azeri
languagesystem latn TRK ; # Turkish
languagesystem latn MOL ; # Moldavian
languagesystem latn ROM ; # Romanian
languagesystem latn CRT ; # Crimean Tatar

then we could write the "case" feature very simply:

Code: [Select]
feature case { # Case-Sensitive Forms
lookup case0 {
    pos @case1 <0 40 0 0>;
    pos at <0 100 0 0>;
    pos [exclamdown questiondown] <0 190 0 0>;
} case0;
lookup case41 {
    sub hyphen by hyphen.case;
} case41;
} case;

This last version reflects on the fact that we want to declare the "case" feature for all languagesystems that we've defined. In that case, it is not necessary to repeat all the script/language entries within the feature definition. If we don't use the script/language keywords within the feature definition at all, then the feature will be declared in all languagesystems that we have listed using the languagesystem statement. You only need to use the script/language statements within feature definitions if you want to declare a feature for some but not all languagesystems (the "locl" feature would be a typical example).
« Last Edit: 2013-04-03, 08:21:23 by Adam Twardoch (FontLab) »
Regards,
Adam Twardoch
Fontlab Ltd.

David Bergsland

  • Hero Member
  • *****
  • Posts: 48
  • Author: "Practical Font Design: Fontographer"
    • The Skilled Workman
    • Email
Re: FEA 2.5 vs. 1.6: "languagesystem" and "script DFLT" issues
« Reply #1 on: 2012-04-02, 15:17:03 »
Thanks, Adam,

I missed this "major" change. At least it was for me. Thanks again.
--
Thanks, David

The Skilled Workman
http://bergsland.org

Bergsland Type foundry
http://www.hackberry-fonts.com

Typography blog:
http://blog.hackberry-fonts.com/

WindDesign

  • Full Member
  • ***
  • Posts: 2
    • Email
Re: FEA 2.5 vs. 1.6: "languagesystem" and "script DFLT" issues
« Reply #2 on: 2014-05-20, 07:34:08 »
Thanks sir !
So can you tell me the abbreaviation of Vietnamese language ?

Example:

Azeri is AZE
Turkish is TRK
Moldavian is MOL
Romanian is ROM
Crimean Tatar is CRT

Thanks in advanced !

Eigi

  • Beta: FontLab Studio Mac
  • Hero Member
  • ***
  • Posts: 100
    • e-font
« Last Edit: 2014-05-20, 07:48:58 by Eigi »