script and language statements in OT features

Ken Krugh's picture

Trying to learn more about features, focusing on the kerning feature at the moment.

In another post Jens Kutilek kindly offered the following feature as a suggestion to a problem I was trying to solve (http://typophile.com/node/72726):

feature kern {
script grek;
language dflt;
pos space <50 0 100 0>;
} kern;

What I'm wondering about is the script and language statements. I've read about them a bit on Adobe's site but, admittedly, will have to back and revisit to better understand. One thing I didn't see is how these statements get used or activated.

Does the application call for them? If so the language statement makes some sense as most apps have a language setting. I don't, though, understand how the script command comes in to play. I've seen it in liga features without a language statement, but again, I don't understand how/when it is implemented.

Also, does anyone know of a source that would be the equivalent to "Features for Dummies?"

Thanks,
Ken
Dummy in Training

agisaak's picture

To answer this, it's probably best to consider some hypothetical feature:

feature test {
  script latn;
    language dflt;
      sub X by Y;
    language TRK include_dflt;
      sub A by B;
    language DEU exclude_dflt;
      sub C by D;
  script cyrl;
    language dflt;
      sub E by F;
} test;

When you compile the above, the font will actually include four different versions of the 'test' feature, and it will be up to the application to determine which of those versions to use when the user activates the 'test' feature (assuming this is a feature which the application allows the user to (de)activate).

The four versions of the feature are as follows:

1. a version which will substitute A by B and X by Y which is intended to be used for Turkish
2. a version which will substitute C by D which is intended to be used for German.
3. a version which will substitute X by Y and which is intended to be used by other languages which employ the Latin script.
4. a version which will substitute E by F and which is intended to be used by languages which use the Cyrillic script.

You'll want to make sure to include appropriate languagesystem declarations at the beginning of your feature file if you want to make use of language tags. These are also described in the OT syntax spec.

André

Ken Krugh's picture

I think I understand the intent of the code, the part I think I'm missing is when each peice of code gets used.

Where is the decision made as to which code gets used? Is it the norm that each peice only gets used when that language is selected in the application?

Thanks again

agisaak's picture

In the example which I give, it is the responsibility of the application to correctly decide which version of the 'test' feature to use. If the user selects a run of text which is marked as being Turkish and then activates the 'test' feature, the application should apply the first version of the feature. If they subsequently apply this feature to a run of text marked as being English, the third version should be applied.

How (or for that matter whether) an application allows a user to specify the language of a particular block of text isn't addressed by OpenType standard.

André

Syndicate content Syndicate content