Set Up Fractions Lookup Rules in FontForge

Setting up OpenType fraction lookup rules in FontForge enables your font to dynamically replace standard number-slash-number sequences (such as 1/2) with properly proportioned typographic fractions. This guide details the essential requirements for building the necessary glyph sets, configuring OpenType Single Substitutions, and assembling the Contextual Chaining rules that govern the fraction (frac) feature.

1. Prepare Required Glyphs

Before defining rules, ensure your font project contains all the necessary components:

  • Standard Figures: zero through nine (U+0030 to U+0039).
  • Fraction Slash: fraction (U+2044) or standard slash (U+002F).
  • Numerators: zero.numr through nine.numr (scaled and raised).
  • Denominators: zero.dnom through nine.dnom (scaled and aligned to the baseline).

2. Create the Single Substitution Lookups

Dynamic fractions require underlying substitution lookups that tell FontForge how to swap full-sized numerals and slashes with their fraction counterparts.

  1. Open Element > Font Info and navigate to the Lookups section in the left sidebar.
  2. Select the GSUB tab at the top.
  3. Click Add Lookup to create the numerator mapping:
    • Type: Select Single Substitution.
    • Feature: Enter or select numr (Numerators).
    • Click OK, select the new lookup, and click Add Subtable.
    • In the subtable window, populate the mapping (e.g., one maps to one.numr, two to two.numr, through nine). Click OK.
  4. Click Add Lookup again to create the denominator mapping:
    • Type: Select Single Substitution.
    • Feature: Enter or select dnom (Denominators).
    • Click OK, select the lookup, click Add Subtable, and map each standard figure to its .dnom counterpart. Click OK.
  5. Click Add Lookup to create a slash substitution:
    • Type: Select Single Substitution.
    • Name the lookup descriptor (e.g., slash_to_fraction). Leave the feature dropdown blank or unassigned if only used as an internal lookup.
    • Add a subtable mapping slash to fraction. Click OK.

3. Create the Contextual Chaining Lookup

The contextual lookup checks the environment surrounding each glyph to determine when to trigger the substitutions.

  1. While still in the GSUB tab, click Add Lookup.
  2. Set Type to Contextual Chaining.
  3. In the Feature list, select or type frac (Fractions).
  4. Click OK, select the newly created frac lookup, and click Add Subtable.
  5. Set the format to By Classes or By Glyphs. Using By Glyphs allows explicit sequences:

Rule A: Numerator Substitution

  • Backtrack: Empty or figures/numerators.
  • Match: Standard figures (zero through nine).
  • Lookahead: The slash glyph (slash or fraction) followed optionally by additional figures.
  • Substitutions: Apply the numr lookup to the matched figure.

Rule B: Slash Substitution

  • Backtrack: Numerators (zero.numr through nine.numr).
  • Match: Standard slash.
  • Lookahead: Standard figures (zero through nine).
  • Substitutions: Apply the slash_to_fraction lookup to replace the slash with fraction.

Rule C: Denominator Substitution

  • Backtrack: The fraction glyph (or fraction preceded by denominators).
  • Match: Standard figures (zero through nine).
  • Lookahead: Empty or figures.
  • Substitutions: Apply the dnom lookup to the matched figure.

4. Test and Validate

  1. Click OK to close all dialog windows and apply the changes.
  2. Open the Metrics window via Metrics > New Metrics Window.
  3. Type a sample fraction sequence such as 1/2 or 3/4.
  4. In the Metrics window, open the Features menu and ensure the frac feature is toggled on to verify that the numbers convert into proper numerators, fraction slashes, and denominators.