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:
zerothroughnine(U+0030 to U+0039). - Fraction Slash:
fraction(U+2044) or standardslash(U+002F). - Numerators:
zero.numrthroughnine.numr(scaled and raised). - Denominators:
zero.dnomthroughnine.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.
- Open Element > Font Info and navigate to the Lookups section in the left sidebar.
- Select the GSUB tab at the top.
- 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.,
onemaps toone.numr,twototwo.numr, throughnine). Click OK.
- Type: Select
- 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
.dnomcounterpart. Click OK.
- Type: Select
- 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
slashtofraction. Click OK.
- Type: Select
3. Create the Contextual Chaining Lookup
The contextual lookup checks the environment surrounding each glyph to determine when to trigger the substitutions.
- While still in the GSUB tab, click Add Lookup.
- Set Type to
Contextual Chaining. - In the Feature list, select or type
frac(Fractions). - Click OK, select the newly created
fraclookup, and click Add Subtable. - 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 (
zerothroughnine). - Lookahead: The slash glyph (
slashorfraction) followed optionally by additional figures. - Substitutions: Apply the
numrlookup to the matched figure.
Rule B: Slash Substitution
- Backtrack: Numerators (
zero.numrthroughnine.numr). - Match: Standard
slash. - Lookahead: Standard figures (
zerothroughnine). - Substitutions: Apply the
slash_to_fractionlookup to replace the slash withfraction.
Rule C: Denominator Substitution
- Backtrack: The
fractionglyph (orfractionpreceded by denominators). - Match: Standard figures (
zerothroughnine). - Lookahead: Empty or figures.
- Substitutions: Apply the
dnomlookup to the matched figure.
4. Test and Validate
- Click OK to close all dialog windows and apply the changes.
- Open the Metrics window via Metrics > New Metrics Window.
- Type a sample fraction sequence such as
1/2or3/4. - In the Metrics window, open the Features menu and
ensure the
fracfeature is toggled on to verify that the numbers convert into proper numerators, fraction slashes, and denominators.