Skip to content

The context block of a rule is rendered seven times in OtlDump #118

Description

@jakejackson1

Follow-up to #117, which added the seventh copy.

OtlDump renders the same block of HTML in seven places: the backtrack, input and lookahead
sequences a context rule matches, and the example fragments each contributes.

$html .= '<div class="context">CONTEXT: ';
for ($ff = count($backtrackGlyphs) - 1; $ff >= 0; $ff--) {
    $html .= '<div>Backtrack #' . $ff . ': <span class="unicode">' . $this->formatUniStr($backtrackGlyphs[$ff]) . '</span></div>';
    $exampleB[] = $this->formatEntityFirst($backtrackGlyphs[$ff]);
}
...
where lookup
OtlDump.php:1140 GSUB 5/1
OtlDump.php:1206 GSUB 5/2
OtlDump.php:1272 GSUB 5/3
OtlDump.php:1351 GSUB 6/1
OtlDump.php:1465 GSUB 6/2
OtlDump.php:1571 GSUB 6/3
OtlDump.php:2857 all six GPOS 7 and 8 formats, in reportGPOSrule()

Six of those are older than #117; the seventh arrived with it, because the GPOS reporters
were written to the shape the GSUB ones already had. reportGPOSrule() is the
generalisation the other six want: it is 1351 line for line, and the class-aware superset
of 1465, which reports class 0 as what it excludes rather than as a list.

What a fix looks like

Lift reportGPOSrule()'s CONTEXT half into a method the seven share. Everything above the
for that walks the lookup records is common; the $class0excl parameter already covers
the one variation, and passing it empty gives the glyph-list form.

What does not share cleanly

The half below it - the $exB/$exL example fragments handed to the nested lookup at
level 2 - is not a drop-in, and the differences are in the output rather than the code:

  • GPOS prepends &#x200d; to each lookahead entry (OtlDump.php:2897) where GSUB appends
    it (OtlDump.php:1399).
  • GSUB calls formatEntity() on each input glyph where GPOS reuses the precomputed
    $exampleI, which is formatEntityFirst().

Whether those are two deliberate renderings or one of them is a bug is worth settling
first, because the tests/data/otldump/*.txt fixtures pin both and a shared version has to
pick one.

Safety

tests/data/otldump/*.txt covers every font in tests/data/ttf and pins this markup
exactly, so a share that leaves all 23 byte-identical has not changed the report.

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancementNew feature or request

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions