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, UnicodeU+2044), which differs in angle and metrics from the regular slash (slash, UnicodeU+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, throughnine.numr. - Denominators: Create scaled-down digits aligned to
the baseline. Name them
zero.dnom,one.dnom,two.dnom, throughnine.dnom.
2. Set Up
Numerator (numr) and Denominator (dnom)
Lookups
Both features use simple Single Substitution lookups:
- Go to Element > Font Info.
- Select Lookups from the left-hand menu, then navigate to the GSUB tab.
- Click Add Lookup.
- Type: Select
Single Substitution. - Feature: Select or type
numr(Numerators). - Click OK.
- Type: Select
- Select the newly created lookup and click Add Subtable.
- In the subtable editor, map the default digits to their
.numrcounterparts (e.g.,one->one.numr). Alternatively, use the automated feature by entering the suffix.numrto populate the list automatically. - Repeat steps 3 through 5 to create a new lookup for
dnom(Denominators), mapping regular digits to their.dnomvariants.
3. Build the Fraction
(frac) Feature
The frac feature combines the components dynamically
when a user types digits separated by a slash:
- Under Font Info > Lookups > GSUB, click Add Lookup.
- Set the Type to
Contextual Chaining Substitution. - Set the Feature to
frac(Fractions). - Add a subtable and define the contextual rules:
- Convert digits preceding a slash into their
numrequivalents. - Replace standard slashes (
U+002F) with the fraction slash (U+2044) when positioned between digits. - Convert digits following the fraction slash into their
dnomequivalents.
- Convert digits preceding a slash into their
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:
- Open the Metrics window via Metrics > New Metrics Window.
- Enter sample text such as
1/2or3/4. - Open the Features menu in the Metrics window and
enable the
fracfeature to confirm that the text shifts to the appropriate numerator, fraction slash, and denominator forms.