Setup Ligature Carets in FontForge Complex Scripts
This article outlines how to configure a ligature caret list in FontForge to ensure proper cursor navigation across combined glyphs in complex scripts. Ligature carets define the intermediate positions where a text cursor stops within a single ligature that represents multiple logical characters. By adding these entry points to the OpenType GDEF table via FontForge, you ensure correct text selection, editing, and caret positioning in layout engines handling complex scripts like Arabic, Devanagari, or contextual Latin scripts.
1. Understand Ligature Caret Requirements
A ligature composed of N individual characters requires N - 1 caret positions. For example, a three-component ligature requires two caret split points.
FontForge supports two methods for defining ligature carets:
- Pixel/Unit Offsets: Absolute horizontal design-unit coordinates relative to the glyph's origin (x = 0).
- Contour Point Anchors: The index number of a specific contour point on the glyph, which preserves position if outlines are modified or scaled.
2. Access the Ligature Caret Interface
- Open your font project in FontForge.
- In the font view, double-click the ligature glyph to open it, or select it and navigate to the menu.
- Choose Element > Glyph Info.
- In the dialog sidebar, select Ligature Caret.
3. Add Caret Positions
- Click the New button to create a caret entry.
- Choose the positioning format:
- Coordinate: Enter the exact X-axis design unit coordinate where the cursor should appear. Measure the logical division points between script components in the glyph edit window beforehand.
- Point: Enter the index number of an on-curve point situated at the junction between the combined shapes.
- Repeat the process for each subsequent boundary inside the ligature.
- Arrange the values in ascending order from left to right along the X-axis. For right-to-left (RTL) scripts such as Arabic, layout engines automatically handle the visual order based on the script direction, but the coordinate values themselves must still align with the physical layout of the glyph coordinate space.
4. Configure GDEF Table Export
Ligature caret data resides in the OpenType GDEF (Glyph
Definition) table.
- Navigate to Element > Font Info > Lookups.
- Ensure that your ligature substitution rules are properly configured under GSUB so the rendering engine recognizes the target glyph as a ligature.
- Open File > Generate Fonts.
- Click the Options button in the file export window.
- Verify that OpenType is checked and ensure there are no options selected that strip GDEF tables upon export.
- Generate the font file (
.otfor.ttf).
5. Validate the Output
Test the generated font in a rendering environment that supports the OpenType GDEF table:
- Use text layout tools like
hb-vieworhb-shape(from the HarfBuzz suite) with caret query flags to verify that cursor stops register at the specified units. - Test in text editors that support complex scripts to confirm that arrow keys navigate cleanly through each sub-character of the ligature without skipping components.