mirror of
https://github.com/mozilla/pdf.js.git
synced 2025-04-22 16:18:08 +02:00
[TrueType] Recover from a missing "glyf" table by replacing it with dummy data, utilizing the existing code in sanitizeGlyphLocations
It seems to be fairly common for OCR software to include incomplete TrueType fonts, notable missing the "glyf" table, in PDF files. Since we currently reject such fonts, the result is that text-selection/copying is broken. This patch contains a suggested approach to try and use these kind of broken fonts, by using existing code in `sanitizeGlyphLocations` to replace a missing "glyf" table with dummy data. Fixes 4684. Fixes 6007. Fixes 6829.
This commit is contained in:
parent
e134947533
commit
d52495a9c8
4 changed files with 19 additions and 2 deletions
|
@ -4154,8 +4154,16 @@ var Font = (function FontClosure() {
|
|||
delete tables['cvt '];
|
||||
this.isOpenType = true;
|
||||
} else {
|
||||
if (!tables.glyf || !tables.loca) {
|
||||
error('Required "glyf" or "loca" tables are not found');
|
||||
if (!tables.loca) {
|
||||
error('Required "loca" table is not found');
|
||||
}
|
||||
if (!tables.glyf) {
|
||||
warn('Required "glyf" table is not found -- trying to recover.');
|
||||
// Note: We use `sanitizeGlyphLocations` to add dummy glyf data below.
|
||||
tables.glyf = {
|
||||
tag: 'glyf',
|
||||
data: new Uint8Array(0),
|
||||
};
|
||||
}
|
||||
this.isOpenType = false;
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue