How to Add Superscript and Subscript in FontForge
Implementing superscript and subscript OpenType features in FontForge allows applications to dynamically replace standard numbers and letters with elevated or lowered variants. This tutorial covers the end-to-end process of setting up these substitutions, including glyph naming conventions, creating OpenType Substitution (GSUB) lookups, mapping standard characters to their modified counterparts, and validating the final font.
1. Create and Name the Variant Glyphs
Before configuring substitutions, you must have the actual superscript and subscript glyphs drawn in your font file.
- Create your scaled-down and vertically shifted glyphs.
- Name each variant using standard OpenType suffix conventions:
- For superscripts, append
.supsto the base glyph name (e.g.,one.sups,two.sups,a.sups). Alternatively, use standard Adobe names likeonesuperior. - For subscripts, append
.substo the base glyph name (e.g.,one.subs,two.subs,a.subs). Alternatively, use standard Adobe names likeoneinferior.
- For superscripts, append
2. Configure the
Superscript (sups) Lookup
Substitutions are handled through the OpenType Layout tables under the Font Info dialog.
- Go to Element > Font Info (or
press
Ctrl+Shift+F/Cmd+Shift+F). - Select Lookups from the left sidebar menu.
- Ensure you are on the GSUB tab at the top.
- Click Add Lookup.
- Set the Type dropdown to Single Substitution.
- Under the Feature column, select or type
sups(Superscript/Superior). - Click OK.
- Select the newly created lookup and click Add Subtable. Accept the default subtable name and click OK.
- In the subtable dialog, populate the mapping:
- Click Populate to automatically match glyphs based
on naming conventions (e.g.,
onetoone.sups), or: - Manually add rows by typing the base glyph name under Base Glyph Name and the replacement under Replacement Glyph Name.
- Click Populate to automatically match glyphs based
on naming conventions (e.g.,
- Click OK to save the subtable.
3. Configure the
Subscript (subs) Lookup
Follow the same procedure to set up subscript substitution:
- In the GSUB lookups panel, click Add Lookup.
- Set the Type to Single Substitution.
- Under Feature, select or type
subs(Subscript/Inferior). - Click OK.
- Select the subscript lookup, click Add Subtable, and accept the name.
- Click Populate to automatically pair
.subsvariants with their base counterparts, or map them manually. - Click OK, then click OK in the main Font Info window to apply changes.
4. Test and Export the Font
- Open a new metrics window via Metrics > New Metrics Window.
- Type a sequence of characters (e.g.,
H2Oorx2). - In the metrics window menu, navigate to Features
and toggle
subsorsupson to confirm the characters swap correctly. - Export your font by choosing File > Generate Fonts, selecting OpenType (CFF) or TrueType, and ensuring OpenType tables are included in the build options.