silnrsi / font-ttf-scripts

Font::TTF::Scripts perl module
Artistic License 2.0
19 stars 7 forks source link

volt2ttf could optimize fmt 2 pair position lookups #14

Open bobh0303 opened 7 years ago

bobh0303 commented 7 years ago

Consider this lookup (from Annapurna 1.100):

ADJUST_PAIR
 FIRST ENUM GLYPH "uni0940" GLYPH "uni0940093C" END_ENUM 
 FIRST ENUM GLYPH "uni0946" GLYPH "uni0946093C" END_ENUM 
 FIRST RANGE "uni0947" TO "uni0947093C.alt" 
 FIRST ENUM GLYPH "uni0948" GLYPH "uni0948093C" END_ENUM 
 FIRST ENUM GLYPH "uni0949" GLYPH "uni0949093C" END_ENUM
 SECOND GLYPH "uni0930094D.reph"
 1 1 BY POS END_POS POS DX 60 END_POS
 3 1 BY POS END_POS POS DX 60 END_POS
 4 1 BY POS END_POS POS DX 140 DY -30 END_POS
 2 1 BY POS END_POS POS DX 150 DY -50 END_POS
 5 1 BY POS END_POS POS DX -400 END_POS
END_ADJUST

When building class-based (fmt2) pair-positioning lookup, volt2ttf currently takes the simplistic approach of defining class values 1-5 for the First glyph, and class value 1 for the Second glyph. This will certainly work.

However, notice that the value record for (1,1) and (3,1) are the same (DX 6). This means that only 4 classes are needed for the First glyph rather than 5. So an optimization is possible that will make for slightly smaller lookups.

VOLT does do this optimization, so currently our fmt2 pair position lookups are not identical to VOLT's (though they function the same).

ref: FTLS-49