How to Create Fraction Substitutions in FontForge

Yes, you can create denominator and numerator substitutions for fractions in FontForge by implementing OpenType layout features. By designing dedicated glyph variants for numerators and denominators, you can map them using the standard OpenType feature tags numr, dnom, and frac. This article outlines the step-by-step process of naming your glyphs, configuring OpenType lookups in FontForge, and compiling dynamic diagonal fractions for any font project.

1. Create the Required Glyphs

Before configuring the substitution rules, you need to design the scaled and positioned glyphs for your fractions:

  • Fraction Slash: Ensure your font contains the standard fraction slash glyph (fraction, Unicode U+2044), which differs in angle and metrics from the regular slash (slash, Unicode U+002F).
  • Numerators: Create scaled-down digits positioned near the cap height or ascender. Use consistent suffix naming such as zero.numr, one.numr, two.numr, through nine.numr.
  • Denominators: Create scaled-down digits aligned to the baseline. Name them zero.dnom, one.dnom, two.dnom, through nine.dnom.

2. Set Up Numerator (numr) and Denominator (dnom) Lookups

Both features use simple Single Substitution lookups:

  1. Go to Element > Font Info.
  2. Select Lookups from the left-hand menu, then navigate to the GSUB tab.
  3. Click Add Lookup.
    • Type: Select Single Substitution.
    • Feature: Select or type numr (Numerators).
    • Click OK.
  4. Select the newly created lookup and click Add Subtable.
  5. In the subtable editor, map the default digits to their .numr counterparts (e.g., one -> one.numr). Alternatively, use the automated feature by entering the suffix .numr to populate the list automatically.
  6. Repeat steps 3 through 5 to create a new lookup for dnom (Denominators), mapping regular digits to their .dnom variants.

3. Build the Fraction (frac) Feature

The frac feature combines the components dynamically when a user types digits separated by a slash:

  1. Under Font Info > Lookups > GSUB, click Add Lookup.
  2. Set the Type to Contextual Chaining Substitution.
  3. Set the Feature to frac (Fractions).
  4. Add a subtable and define the contextual rules:
    • Convert digits preceding a slash into their numr equivalents.
    • Replace standard slashes (U+002F) with the fraction slash (U+2044) when positioned between digits.
    • Convert digits following the fraction slash into their dnom equivalents.

For arbitrary or pre-composed fractions (like 1/2 or 3/4), you can also use a Ligature Substitution lookup under the frac tag that substitutes specific sequences (e.g., one + slash + two) directly with a pre-drawn fraction glyph (e.g., onehalf).

4. Test the Substitutions

To verify your configuration within FontForge:

  1. Open the Metrics window via Metrics > New Metrics Window.
  2. Enter sample text such as 1/2 or 3/4.
  3. Open the Features menu in the Metrics window and enable the frac feature to confirm that the text shifts to the appropriate numerator, fraction slash, and denominator forms.