OpenType Feature Fractions

  • feature numr
  • feature dnom
  • feature frac
  • feature sups
  • feature subs
  • feature sinf
  • feature ordn
  • feature tnum
  • feature onum
  • feature pnum
  • feature lnum
  • feature zero
  • feature locl
  • feature ccmp
  • feature case
  • feature c2sc
  • feature smcp
  • feature liga
  • feature dlig

Fractions

Let’s we start with creation of fractions. Open your text editor – for example Notepad (I prefer Notepad++) – and save the empty file under the name features.fea. This file and what we write in it will rule the OpenType features of our font.
Our file will include these sections:

1. Class Definitions
2. Languagesystem
3. Feature AALT
4. Feature’s Definitions

1. CLASS DEFINITIONS
@frac1=[zero.dnom one.dnom two.dnom three.dnom four.dnom five.dnom six.dnom seven.dnom eight.dnom nine.dnom];
@frac2=[zero one two three four five six seven eight nine];
@frac3=[zero.numr one.numr two.numr three.numr four.numr five.numr six.numr seven.numr eight.numr nine.numr];

Here is our first class @FRAC1. It consist of denominator glyphs, which we need to have in our font, so that we to be able to use them for the fractions.

0
1
2
3
4
5
6
7
8
9

Here is our second class @FRAC2. It consist of default digits.

0
1
2
3
4
5
6
7
8
9

Here is our third class @FRAC3. It consist of numerator glyphs.

0
1
2
3
4
5
6
7
8
9

Now we have default digits, denominators and numerators – and their classes too. It’s time to put the record of our classes in the begining of our feature.fea file.
Our next step is to write the languagesystems.

2. LANGUAGESYSTEM
languagesystem DFLT dflt;
languagesystem cyrl dflt;
languagesystem cyrl BGR ;
languagesystem latn dflt;

By the LANGUAGESYSTEM record we define which languages are supported in our font by default and as exceptions. The record languagesystem cyrl BGR tell us that there will be a special exception for Bulgarian language in our font. This exception will not be in the fractions, but in spite of that let’s we have this record for the next features (specially for the feature locl).

Now we have default digits, denominators and numerators – and their classes too. We have the languagesystem record. It’s time to add AALT feature in our feature.fea file.

3. FEATURE AALT
feature aalt {
feature frac;
} aalt;

This feature AALT (Access all Alternates) makes all variations of a selected character accessible. This serves several purposes: An application may not support the feature by which the desired glyph would normally be accessed; the user may need a glyph outside the context supported by the normal substitution, or the user may not know what feature produces the desired glyph. Since many-to-one substitutions are not covered, ligatures would not appear in this table unless they were variant forms of another ligature.

Now we have default digits, denominators and numerators – and their classes too. We have the languagesystem record. We have added FEATURE FRAC to AALt. It’s time to write the record for FEATURE FRAC in our feature.fea file.

4. FEATURE FRAC
feature frac {
lookup frac2 {
sub slash by fraction;
} frac2;
lookup frac3 {
sub @frac2 by @frac3;
} frac3;
lookup frac4 {
sub fraction @frac3′ by [zero.dnom one.dnom two.dnom three.dnom four.dnom five.dnom six.dnom seven.dnom eight.dnom nine.dnom];
} frac4;
lookup frac5 {
sub @frac1 @frac3′ by [zero.dnom one.dnom two.dnom three.dnom four.dnom five.dnom six.dnom seven.dnom eight.dnom nine.dnom];
} frac5;
script latn;
lookup frac2;
lookup frac3;
lookup frac4;
lookup frac5;
script cyrl;
lookup frac2;
lookup frac3;
lookup frac4;
lookup frac5;
} frac;

Here is our FEATURE FRAC. It consists of 2 main parts.
In the first part we define LOOKUPS (every lookup has its own name from frac2 to frac5).
In lookup frac2 we substitute slash by fraction.
In lookup frac3 we substitute class @frac2 (all default digits) by class @frac3 (all numerators).
In lookup frac4 if numarator of class @frac3 is preceded by the glyph fraction, it is turned to be denominator.
In lookup frac5 if any numerator of class @frac3 is preceded by denominator it is turned to be denominator.
And our final step is to spread the lookups among the scipts and languages. We do this for script latn, then for script cyrl etc.
We have saved our opentype features as a separate feture.fea file and now we could import this file and its records in our main font creator.

Further Readings

Tal Leming: The Unofficial OpenType Cookbook
Martin Wenzel, Christoph Koeberlin: An Introduction to OpenType Substitution Features
Glyphs: Tutorials Tagged “OpenType Features”

Remarks

Stefan Peev

Stefan Peev is a graphic designer and typographer from Bulgaria.

 

If you like this site and find it useful, help us to make it better by giving feedback, suggesting improvements or by donation.

Donate

This site uses Akismet to reduce spam. Learn how your comment data is processed.