Skip to content

Sun-ExtA.ttf has a malformed vhea table, so browsers reject it #881

Closed

Description

@gravitypdf-bot

Sun-ExtA.ttf has a malformed vhea table, so browsers refuse to load it as a web font. It came up in the Font Manager preview in GravityPDF/gravity-pdf#2015, using the copy published at GravityPDF/mpdf-core-fonts v1.1.1.

The fault

vhea.numberOfVMetrics is 57,514, but maxp.numGlyphs is 50,016. Firefox and Chromium both run fonts through the OpenType Sanitizer, which treats this as fatal:

downloadable font: vhea: Bad number of metrics 57514
downloadable font: vhea: Failed to parse table
downloadable font: rejected by sanitizer
OTS parsing error: vhea: Bad number of metrics 57514

Of the 39 regular-style core font files checked, this is the only one where vhea or hhea claims more metrics than there are glyphs.

Proposed fix

Remove the vertical layout tables (vhea, vmtx, VORG) and publish the repaired file. TTFontFile.php doesn't reference any of them.

Tested on a scratch copy with fontTools, using recalcBBoxes=False and recalcTimestamp=False:

  • Firefox and Chromium load the repaired file, and still reject the original.
  • The character map and glyph count are unchanged.
  • The file goes from 22,993,540 to 22,748,504 bytes.

Not tested yet: rendering a PDF with the repaired file, including CJK text and backupSubsFont substitution. That should happen before it's released.

Follow-up in Gravity PDF

Once a repaired file is published:

  • Update its URL, size and hash in fonts/core-fonts.php and fonts/core-fonts.json.
  • Remove 'preview' => false from sun-exta in Model_Font_Languages.
  • Check what compares a file already on disk against the new hash. A download is skipped when the file exists, so existing sites keep the old copy, which still can't be previewed.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions