OpenType Features: Order of Precedence

Post general font related questions (e.g. how to install, convert and use fonts) and requests (looking for fonts, designers etc.) here.
Bhikkhu Pesala
Top Typographer
Top Typographer
Posts: 7083
Joined: Tue Oct 29, 2002 5:28 am
Location: Seven Kings, London UK
Contact:

OpenType Features: Order of Precedence

Post by Bhikkhu Pesala » Mon Dec 10, 2012 10:25 am

I found that the features which appear first in my script file will override those that follow if both are enabled by the user:
  1. feature AlternativeFractions;
  2. feature ScientificInferiors;
  3. feature Subscript;
  4. feature Superscript;
  5. feature Ordinals;
  6. feature Denominators;
  7. feature Numerators;
  8. feature Fractions;
  9. feature AlternateAnnotationForms;
  10. feature OldStyleFigures;
  11. feature DiscretionaryLigatures;
  12. feature Ligatures;
  13. feature Ornaments;
  14. feature StylisticAlternates;
  15. feature TerminalForms;
  16. feature HistoricalLigatures;
  17. feature HistoricalForms;
For example, if the user enables both superscripts and subscripts, the subscripts will take precedence. If they enable scientific inferiors and subscripts, then scientific inferiors (below baseline subscripts) will take precedence, etc.

Its not difficult to change the order of precedence, but its hard to decide which should be the highest priority. We cannot always rely on users remembering to disable one feature when using another.
My FontsReviews: MainTypeFont CreatorHelpFC11.0 Pro + MT7.0 @ Win10 1703

Erwin Denissen
Moderator
Moderator
Posts: 6903
Joined: Fri Oct 04, 2002 12:41 am
Location: De Bilt, The Netherlands
Contact:

Re: OpenType Features: Order of Precedence

Post by Erwin Denissen » Thu Aug 21, 2014 3:26 pm

I just came around this topic, and don't understand it as I thought the order of features is always alphabetical (the order of lookups in a feature can be important though). Maybe a bug in a old version of FontCreator caused the confusion, but maybe I need some rest :wink:
Erwin Denissen
High-Logic
Proven Font Technology

Bhikkhu Pesala
Top Typographer
Top Typographer
Posts: 7083
Joined: Tue Oct 29, 2002 5:28 am
Location: Seven Kings, London UK
Contact:

Re: OpenType Features: Order of Precedence

Post by Bhikkhu Pesala » Wed Aug 27, 2014 5:36 pm

Do look at this again, when you have had some rest.

If both Small Capitals and Standard Ligatures are enabled in PagePlus.
  • If the Small Capitals feature is listed first, all is well. “Affect” is displayed as AFFECT
  • If the Ligature feature is listed first: “Affect” is displayed as AffECT
My FontsReviews: MainTypeFont CreatorHelpFC11.0 Pro + MT7.0 @ Win10 1703

Erwin Denissen
Moderator
Moderator
Posts: 6903
Joined: Fri Oct 04, 2002 12:41 am
Location: De Bilt, The Netherlands
Contact:

Re: OpenType Features: Order of Precedence

Post by Erwin Denissen » Thu Aug 28, 2014 11:11 am

Can you please send me two versions of your font so I can further look into this.
Erwin Denissen
High-Logic
Proven Font Technology

Bhikkhu Pesala
Top Typographer
Top Typographer
Posts: 7083
Joined: Tue Oct 29, 2002 5:28 am
Location: Seven Kings, London UK
Contact:

Re: OpenType Features: Order of Precedence

Post by Bhikkhu Pesala » Thu Aug 28, 2014 11:51 am

The first font has Standard Ligatures defined at the end of the script, the borked edition has it at the beginning.
Attachments
Sukhumala Hand Tooled.fcp
(274.62 KiB) Downloaded 63 times
My FontsReviews: MainTypeFont CreatorHelpFC11.0 Pro + MT7.0 @ Win10 1703

Erwin Denissen
Moderator
Moderator
Posts: 6903
Joined: Fri Oct 04, 2002 12:41 am
Location: De Bilt, The Netherlands
Contact:

Re: OpenType Features: Order of Precedence

Post by Erwin Denissen » Thu Aug 28, 2014 12:06 pm

Thank you for your fast response!

The exported fonts are both exactly the same, so I still don't understand why you see a difference.
Erwin Denissen
High-Logic
Proven Font Technology

Bhikkhu Pesala
Top Typographer
Top Typographer
Posts: 7083
Joined: Tue Oct 29, 2002 5:28 am
Location: Seven Kings, London UK
Contact:

Re: OpenType Features: Order of Precedence

Post by Bhikkhu Pesala » Thu Aug 28, 2014 12:42 pm

OK. Then try this one: WOFF test shows the error now.

The Standard Ligature feature was moved to the front

script latn {
feature StandardLigatures;
Attachments
Sukhumala Hand Tooled Borked.fcp
(274.64 KiB) Downloaded 62 times
My FontsReviews: MainTypeFont CreatorHelpFC11.0 Pro + MT7.0 @ Win10 1703

Erwin Denissen
Moderator
Moderator
Posts: 6903
Joined: Fri Oct 04, 2002 12:41 am
Location: De Bilt, The Netherlands
Contact:

Re: OpenType Features: Order of Precedence

Post by Erwin Denissen » Thu Aug 28, 2014 2:37 pm

Here is what I've found so far about the importance of the OpenType feature order.

When I test your fonts in Internet Explorer (IE11) it is clear the feature order is indeed important!
preview1.png
preview1.png (29.43 KiB) Viewed 6212 times
preview2.png
preview2.png (28.73 KiB) Viewed 6212 times
Mozilla Firefox (which uses HarfBuzz) seems to process features based on the order in the font as well. Other OpenType layout engines might behave different mainly because of unclear, incorrect, or outdated parts of the OpenType specifications which leads to different interpretations.
Erwin Denissen wrote:I just came around this topic, and don't understand it as I thought the order of features is always alphabetical (the order of lookups in a feature can be important though). Maybe a bug in a old version of FontCreator caused the confusion, but maybe I need some rest :wink:
The order of features in the FeatureList table is stored alphabetically by FeatureTag as this is a requirement by the specs. However the LangSys table contains indexes to the FeatureList table in an arbitrary order. See specs:
http://www.microsoft.com/typography/otspec/chapter2.htm

It seems the order of the feature indexes in the LangSys table is of importance, but I understood the engine decides the processing order of the features, while it looks like even though the specs describe the order, it is up to the font designer to order the features :?
Regardless of the model an application chooses for supporting layout of complex scripts, Uniscribe requires a fixed order for executing features within a run of text to consistently obtain the proper basic form. The feature order is different for each script or language system and is described within those documents.
Source: Microsoft -> OpenType Development Specification

For standard scripts (e.g. Latin) the processing order is as follows:
order for standard scripts.png
order for standard scripts.png (15.11 KiB) Viewed 6212 times
Source: Microsoft -> Developing OpenType Fonts for Standard Scripts

Not a word about the order of other features though. So maybe this is not a required but a recommended order?

I either still don't understand this part "The feature order is different for each script or language system and is described within those documents." or it is plain wrong.

Conclusion, you are right, the order can be important.
Erwin Denissen
High-Logic
Proven Font Technology

Bhikkhu Pesala
Top Typographer
Top Typographer
Posts: 7083
Joined: Tue Oct 29, 2002 5:28 am
Location: Seven Kings, London UK
Contact:

Re: OpenType Features: Order of Precedence

Post by Bhikkhu Pesala » Thu Aug 28, 2014 5:01 pm

Erwin Denissen wrote:I either still don't understand this part "The feature order is different for each script or language system and is described within those documents." or it is plain wrong.
Suppose my font has both Petite Caps and Small Caps features, for both Latin and Greek characters. However, suppose the Greek lowercase characters are bigger than the latin ones.

For Latin I could have:

feature PetiteCapitals;
feature SmallCapitals;

But for Greek I could have:

feature SmallCapitals;
feature PetiteCapitals;

Then, the user can choose either Small or Petite Capitals as appropriate. If both are selected, the Petite Capitals would be used for Latin but the Small Capitals would be used for Greek.

I assume that that is the reasoning behind allowing the font designer to decide on the order of precedence.

My reason for starting this thread was to get suggestions regarding which features should take precedence, i.e. which should come first in the script?
My FontsReviews: MainTypeFont CreatorHelpFC11.0 Pro + MT7.0 @ Win10 1703

Erwin Denissen
Moderator
Moderator
Posts: 6903
Joined: Fri Oct 04, 2002 12:41 am
Location: De Bilt, The Netherlands
Contact:

Re: OpenType Features: Order of Precedence

Post by Erwin Denissen » Tue Sep 02, 2014 3:29 pm

Fortunately Leon did implement ordering both features and lookups, so all is possible with FontCreator :D
Bhikkhu Pesala wrote:My reason for starting this thread was to get suggestions regarding which features should take precedence, i.e. which should come first in the script?
I read a post about this at typophile. You've probably seen it as well, but just in case:

Adam Twardoch from FontLab wrote:
"one rule of thumb is that the features that are more semantic, orthographic or linguistic should be processed as early as possible, while the features that are more visual or typographic should be processed later. Another rule of thumb is that within the visual features, the features that perform a more dramatic visual change to the whole of text should be processed earlier than those that only perform minor changes."
Source: OpenType Features order (related to Stylistic Sets)

He also provides some more in depth information. I hope it helps.
Erwin Denissen
High-Logic
Proven Font Technology

Richard W
Posts: 8
Joined: Mon Sep 28, 2015 7:41 pm

Re: OpenType Features: Order of Precedence

Post by Richard W » Wed Sep 30, 2015 8:25 pm

Erwin Denissen wrote: I either still don't understand this part "The feature order is different for each script or language system and is described within those documents." or it is plain wrong.
The complication arises because some features work together with re-ordering, principally for Indic scripts. Features are processed in batches, and sometimes glyphs are reordered if they result from the operation of a particular feature. Within each batch, the lookups of the features are processed in the order in which their lookup definitions are stored in the font file.

How the reordering and batching are done are in general dependent on the script. Applications have some control on which features are taken account of, though it was noticeable with IE11 (at least, early IE11), that I could not induce IE11 to apply general typographical features to 'non-standard' scripts. Firefox, which uses HarfBuzz for rendering, is more accommodating.

Erwin Denissen
Moderator
Moderator
Posts: 6903
Joined: Fri Oct 04, 2002 12:41 am
Location: De Bilt, The Netherlands
Contact:

Re: OpenType Features: Order of Precedence

Post by Erwin Denissen » Wed Nov 09, 2016 3:34 pm

A more recent topic includes information which might help:
Changing the Order of Precedence of OpenType Features
Erwin Denissen
High-Logic
Proven Font Technology

MikeW
Posts: 483
Joined: Mon May 20, 2013 2:51 pm

OpenType Features: Order of Precedence

Post by MikeW » Sun May 07, 2017 4:32 pm

Like this, BP?
capture-001067.png
capture-001068.png

Bhikkhu Pesala
Top Typographer
Top Typographer
Posts: 7083
Joined: Tue Oct 29, 2002 5:28 am
Location: Seven Kings, London UK
Contact:

Re: OpenType Features: Order of Precedence

Post by Bhikkhu Pesala » Sun May 07, 2017 5:00 pm

Bhikkhu Pesala wrote:Feel free to download my Mandala font and see if you can come up with a solution. The linked thread would be a good place to report your findings.
MikeW wrote:Like this, BP?
There is no way to tell how this works without the font project whether the Fraction feature is the same as in my fonts.
My FontsReviews: MainTypeFont CreatorHelpFC11.0 Pro + MT7.0 @ Win10 1703

MikeW
Posts: 483
Joined: Mon May 20, 2013 2:51 pm

Re: OpenType Features: Order of Precedence

Post by MikeW » Sun May 07, 2017 5:09 pm

Cannot share the font project. However, the ordinals is a chaining context and the code is:

lookup ChainingContext15 {
context (@Numerals) @ords;
sub 0 MultipleSubstitution2;
context (@ords2) @ords;
sub 0 MultipleSubstitution2;
}

@ords is simply the alpha characters I use (which isn't the entire lower case available).
@ords2 is simply the same alpha characters as above but superscript versions.

The substitution (MultipleSubstitution2 is simply swaping the two ords classes above. The fractions are arbitrary and each of the features (frac, ordn) can be turned off/on globally with "harming" percentages, etc. If needed, I can create a sample in some OFL font.

Post Reply

Who is online

Users browsing this forum: No registered users and 1 guest