Skip to content

Conversation

anthrotype
Copy link
Member

@anthrotype anthrotype commented Aug 13, 2025

Fixes #3843

Sometimes hmtx or vmtx may appear truncated with not enough data to decompile the list of sidebearings at the end of the table. Currently an IndexError would be thrown which is confusing.

ERROR: An exception occurred during the decompilation of the 'vmtx' table
Traceback (most recent call last):
  File "fontTools/ttLib/ttFont.py", line 468, in _readTable
    table.decompile(data, self)
  File "fontTools/ttLib/tables/_h_m_t_x.py", line 67, in decompile
    self.metrics[glyphName] = (lastAdvance, sideBearings[i])
                                            ~~~~~~~~~~~~^^^
IndexError: array index out of range
Dumping 'vmtx' table...

This PR makes it so we raise the same TTLibError(f"not enough {tableTag} data") that we already raise when we don't have enough table data to decompile the "long" metrics.

…ncated

Address #3843

previously we were only raising if table size was smaller than expected (numGlyphs * numberOfLongMetrics); now we also include the sidebearings to compute the expected minimum table size and raise the same error when the table appears to be truncated (i.e. not enough data to decompile sidebearings)
@anthrotype anthrotype merged commit 1ea2a47 into main Aug 14, 2025
11 checks passed
@anthrotype anthrotype deleted the improve-vhmtx-error branch August 14, 2025 09:34
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

[ttx] "An exception occurred during the decompilation of the 'vmtx' table"
1 participant