-
Notifications
You must be signed in to change notification settings - Fork 10.2k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Fix bad truetype loca tables. #12186
Conversation
/botio test |
From: Bot.io (Linux m4)ReceivedCommand cmd_test from @brendandahl received. Current queue size: 0 Live output at: http://54.67.70.0:8877/51f7b098febb263/output.txt |
From: Bot.io (Windows)ReceivedCommand cmd_test from @brendandahl received. Current queue size: 0 Live output at: http://54.215.176.217:8877/d27ba7b7c878286/output.txt |
From: Bot.io (Linux m4)FailedFull output at http://54.67.70.0:8877/51f7b098febb263/output.txt Total script time: 27.20 mins
Image differences available at: http://54.67.70.0:8877/51f7b098febb263/reftest-analyzer.html#web=eq.log |
From: Bot.io (Windows)FailedFull output at http://54.215.176.217:8877/d27ba7b7c878286/output.txt Total script time: 30.13 mins
Image differences available at: http://54.215.176.217:8877/d27ba7b7c878286/reftest-analyzer.html#web=eq.log |
/botio-linux preview |
From: Bot.io (Linux m4)ReceivedCommand cmd_preview from @Snuffleupagus received. Current queue size: 0 Live output at: http://54.67.70.0:8877/4aee4742d547f8a/output.txt |
From: Bot.io (Linux m4)SuccessFull output at http://54.67.70.0:8877/4aee4742d547f8a/output.txt Total script time: 3.46 mins Published |
src/core/fonts.js
Outdated
// Now the offsets are sorted, calculate the end offset of each glyph. | ||
for (i = 0; i < numGlyphs; i++) { | ||
locaEntries[i].endOffset = locaEntries[i + 1].offset; | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Doesn't this mean that the last loca-table entry will always have a zero endOffset
, i.e. locaEntries[numGlyphs].endOffset === 0
; is that not a problem?
Unless I'm overlooking something here, this means that sanitizeGlyph
will just reject the glyph since it's deemed empty!?
Edit: Naively, I'd expect that adding something like the below might work, but I could also be completely wrong :-)
locaEntries[numGlyphs].endOffset = oldGlyfDataLength - locaEntries[numGlyphs].offset;
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It's a bit confusing since there are numGlyphs + 1
loca entries. Down below we don't iterate over the last loca entry (i < numGlyphs
), but it's data is effectively saved in the previous entry when endOffset is read here.
I think I'll add some more comments, and maybe change the above i <= numGlyphs
to i < numGlyphs + 1
to make it more explicit.
src/core/fonts.js
Outdated
|
||
// The spec says the offsets should be in ascending order, however | ||
// this is not true for some fonts or they use the offset of 0 to mark a | ||
// glyph as missing. OTS requires the offsets in order and not to |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nit: Looks like a missing "to be" here, i.e. it probably should read:
// glyph as missing. OTS requires the offsets to be in order and not to
Some fonts have loca tables that aren't sorted or use 0 as an offset to signal a missing glyph. This fixes the bad loca tables by sorting them and then rewriting the loca table and potentially re-ordering the glyf table to match. Fixes mozilla#11131 and bug 1650302.
/botio test |
From: Bot.io (Windows)ReceivedCommand cmd_test from @brendandahl received. Current queue size: 0 Live output at: http://54.215.176.217:8877/bf371e99f6beef8/output.txt |
From: Bot.io (Linux m4)ReceivedCommand cmd_test from @brendandahl received. Current queue size: 0 Live output at: http://54.67.70.0:8877/48a6fbd7d69dca4/output.txt |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
r=me, with passing tests; really nice work fixing a bunch of font bugs all at once!
From: Bot.io (Linux m4)FailedFull output at http://54.67.70.0:8877/48a6fbd7d69dca4/output.txt Total script time: 27.03 mins
Image differences available at: http://54.67.70.0:8877/48a6fbd7d69dca4/reftest-analyzer.html#web=eq.log |
From: Bot.io (Windows)FailedFull output at http://54.215.176.217:8877/bf371e99f6beef8/output.txt Total script time: 29.11 mins
Image differences available at: http://54.215.176.217:8877/bf371e99f6beef8/reftest-analyzer.html#web=eq.log |
/botio makeref |
From: Bot.io (Linux m4)ReceivedCommand cmd_makeref from @brendandahl received. Current queue size: 0 Live output at: http://54.67.70.0:8877/2c9ac166d2bdae6/output.txt |
From: Bot.io (Windows)ReceivedCommand cmd_makeref from @brendandahl received. Current queue size: 0 Live output at: http://54.215.176.217:8877/72c9b95dea13939/output.txt |
From: Bot.io (Linux m4)SuccessFull output at http://54.67.70.0:8877/2c9ac166d2bdae6/output.txt Total script time: 25.25 mins
|
From: Bot.io (Windows)SuccessFull output at http://54.215.176.217:8877/72c9b95dea13939/output.txt Total script time: 29.73 mins
|
Some fonts have loca tables that aren't sorted or use 0 as an offset to
signal a missing glyph. This fixes the bad loca tables by sorting them
and then rewriting the loca table and potentially re-ordering the glyf
table to match.
Fixes #11131, #11561
and
https://bugzilla.mozilla.org/show_bug.cgi?id=1650302
https://bugzilla.mozilla.org/show_bug.cgi?id=846014
https://bugzilla.mozilla.org/show_bug.cgi?id=844092