Error Export: GSUB Subtable Overflow in lookup

Hi there,

I’ve a handwritting style font with more than 2300 alternative character (ss01).
And also I designed a contextual alternates role (A’ denotes the ss01 glyph) that:

  1. A
  2. A’A
  3. A’BA
  4. A’BCA
    ( B and C can be any other glyphs)

With the concept, I have more than 9000 lines in calt feature, such as:

lookup SUB_CALT useExtension{
	ignore sub uni3904.ss01 uni3904' uni3904 uni3904;
	sub uni3904' uni3904 by uni3904.ss01;
	sub uni3904' @DEFAULT uni3904 by uni3904.ss01;
	sub uni3904' @DEFAULT @DEFAULT uni3904 by uni3904.ss01;
	ignore sub uni39FE.ss01 uni39FE' uni39FE uni39FE;
	sub uni39FE' uni39FE by uni39FE.ss01;
	sub uni39FE' @DEFAULT uni39FE by uni39FE.ss01;
	sub uni39FE' @DEFAULT @DEFAULT uni39FE by uni39FE.ss01;
    (...)
} SUB_CALT

where @DEFAULT is a class contains all characters without *.ss01.

I’ve tried only write few character calt rule and the font can export succefully.

However, when I add the entire calt into font info, the export processing get a warning that Subtable Overflow in lookup: 0 type: single. I guess that the subtable has a upper limit size (how much?).

截圖 2022-12-15 18.58.43

Following the OpenType Feature File Specification | afdko guide, I added a useExtension tag after the lookup function, and I enabled Use Extension Kerning in custom parameter, but it still failed for exporting.

How to extend the GSUB table for editing more rule?
Or does there have a better solution for my calt idea?
Or can I edit the font feature via *.ttx file directly ( I can parse it via fonttool)?

Thank you

Yes. Each lookup needs to fit within 64k.

  • Try to define smaller lookups first, and put the biggest last. You can define them in a Prefix. The order of their definition counts.
  • Consider making the rules more general, with classes instead of single glyphs. That saves some space as well.

Put the substitution in separate lookups.
Split the SUB_CALT into multiple lookups. Comment out lines starting from the end of the code. Try to export. Keep doing that until it works. There you add a new lookup.

But you might find an algorithm that produces a very similar result but with less code. Have you read the tutorials about contextual substitutions and Randomness?