Follow-up to #90, which added the second copy.
Otl and OtlDump each decode the six GPOS contextual positioning subtable layouts, from
the spec, independently.
| format |
applied in Otl |
reported in OtlDump |
| 7/1 |
_applyGPOScontextPosFormat1, Otl.php:3930 |
reportGPOScontextPosFormat1, OtlDump.php:2563 |
| 7/2 |
Otl.php:3988 |
OtlDump.php:2620 |
| 7/3 |
Otl.php:4074 |
OtlDump.php:2677 |
| 8/1 |
Otl.php:4115 |
OtlDump.php:2711 |
| 8/2 |
Otl.php:4183 |
OtlDump.php:2764 |
| 8/3 |
Otl.php:4314 |
OtlDump.php:2821 |
Both walk the same records in the same order - a PosRuleSet chosen by coverage index, then
glyphCount, posCount, the input sequence one short of its count, then the
PosLookupRecords - and both had to get the one ordering trap right independently: Type 7
Format 3 puts posCount before the Coverage offsets where Type 8 Format 3 puts it after.
This is the same shape #112 was about, one level down. There the two copies had already
drifted; these two have not yet, because one of them is four weeks old.
Why it is not simply #112 again
The obvious fix - have the parser record what it read and the dump render it - does not
apply here, and #90 says why. TTFontFile never parses a GPOS subtable: it reads position
0's Coverage for the shaper's gate and nothing else. Making it parse all six layouts would
slow every font-cache build for the benefit of a debugging page.
So the sharing has to be at the level below both: the primitives, not the structures.
Where to look
OtlDump.php:2926-3010 already has them, extracted while #90 was written:
coverageOffsets() the Coverage offsets of one sequence, read in place
coverageGlyphs() follow them
posLookupRecords() SequenceIndex + LookupListIndex pairs
glyphSequence() a sequence naming one glyph per position
classSequence() a sequence naming one class per position
Those are five methods that take a FontReader and return a structure, which is exactly
the shape of Mpdf\Fonts\Table\Coverage and Mpdf\Fonts\Table\ClassDef. Moving them there
and having both Otl and OtlDump call them would leave each side with its own reason for
reading - applying against the run, or rendering - and one copy of the layout.
Safety
tests/data/fontcache/*.json, tests/data/otldump/*.txt and tests/data/shaping/*.txt
between them pin both sides for every font in tests/data/ttf. Note that 7/2 is covered by
neither, for the reason in the issue filed alongside this one.
Follow-up to #90, which added the second copy.
OtlandOtlDumpeach decode the six GPOS contextual positioning subtable layouts, fromthe spec, independently.
OtlOtlDump_applyGPOScontextPosFormat1,Otl.php:3930reportGPOScontextPosFormat1,OtlDump.php:2563Otl.php:3988OtlDump.php:2620Otl.php:4074OtlDump.php:2677Otl.php:4115OtlDump.php:2711Otl.php:4183OtlDump.php:2764Otl.php:4314OtlDump.php:2821Both walk the same records in the same order - a PosRuleSet chosen by coverage index, then
glyphCount,posCount, the input sequence one short of its count, then thePosLookupRecords - and both had to get the one ordering trap right independently: Type 7
Format 3 puts
posCountbefore the Coverage offsets where Type 8 Format 3 puts it after.This is the same shape #112 was about, one level down. There the two copies had already
drifted; these two have not yet, because one of them is four weeks old.
Why it is not simply #112 again
The obvious fix - have the parser record what it read and the dump render it - does not
apply here, and #90 says why.
TTFontFilenever parses a GPOS subtable: it reads position0's Coverage for the shaper's gate and nothing else. Making it parse all six layouts would
slow every font-cache build for the benefit of a debugging page.
So the sharing has to be at the level below both: the primitives, not the structures.
Where to look
OtlDump.php:2926-3010already has them, extracted while #90 was written:Those are five methods that take a
FontReaderand return a structure, which is exactlythe shape of
Mpdf\Fonts\Table\CoverageandMpdf\Fonts\Table\ClassDef. Moving them thereand having both
OtlandOtlDumpcall them would leave each side with its own reason forreading - applying against the run, or rendering - and one copy of the layout.
Safety
tests/data/fontcache/*.json,tests/data/otldump/*.txtandtests/data/shaping/*.txtbetween them pin both sides for every font in
tests/data/ttf. Note that 7/2 is covered byneither, for the reason in the issue filed alongside this one.