Merge pull request #14882 from Snuffleupagus/issue-14881
Add support for TrueType format 12 `cmap`s (issue 14881)
This commit is contained in:
commit
f8838eb794
@ -1499,14 +1499,14 @@ class Font {
|
||||
}
|
||||
|
||||
const format = file.getUint16();
|
||||
file.skip(2 + 2); // length + language
|
||||
|
||||
let hasShortCmap = false;
|
||||
const mappings = [];
|
||||
let j, glyphId;
|
||||
|
||||
// TODO(mack): refactor this cmap subtable reading logic out
|
||||
if (format === 0) {
|
||||
file.skip(2 + 2); // length + language
|
||||
|
||||
for (j = 0; j < 256; j++) {
|
||||
const index = file.getByte();
|
||||
if (!index) {
|
||||
@ -1519,6 +1519,8 @@ class Font {
|
||||
}
|
||||
hasShortCmap = true;
|
||||
} else if (format === 2) {
|
||||
file.skip(2 + 2); // length + language
|
||||
|
||||
const subHeaderKeys = [];
|
||||
let maxSubHeaderKey = 0;
|
||||
// Read subHeaderKeys. If subHeaderKeys[i] === 0, then i is a
|
||||
@ -1568,6 +1570,8 @@ class Font {
|
||||
}
|
||||
}
|
||||
} else if (format === 4) {
|
||||
file.skip(2 + 2); // length + language
|
||||
|
||||
// re-creating the table in format 4 since the encoding
|
||||
// might be changed
|
||||
const segCount = file.getUint16() >> 1;
|
||||
@ -1630,6 +1634,8 @@ class Font {
|
||||
}
|
||||
}
|
||||
} else if (format === 6) {
|
||||
file.skip(2 + 2); // length + language
|
||||
|
||||
// Format 6 is a 2-bytes dense mapping, which means the font data
|
||||
// lives glue together even if they are pretty far in the unicode
|
||||
// table. (This looks weird, so I can have missed something), this
|
||||
@ -1647,6 +1653,26 @@ class Font {
|
||||
glyphId,
|
||||
});
|
||||
}
|
||||
} else if (format === 12) {
|
||||
file.skip(2 + 4 + 4); // reserved + length + language
|
||||
|
||||
const nGroups = file.getInt32() >>> 0;
|
||||
for (j = 0; j < nGroups; j++) {
|
||||
const startCharCode = file.getInt32() >>> 0;
|
||||
const endCharCode = file.getInt32() >>> 0;
|
||||
let glyphCode = file.getInt32() >>> 0;
|
||||
|
||||
for (
|
||||
let charCode = startCharCode;
|
||||
charCode <= endCharCode;
|
||||
charCode++
|
||||
) {
|
||||
mappings.push({
|
||||
charCode,
|
||||
glyphId: glyphCode++,
|
||||
});
|
||||
}
|
||||
}
|
||||
} else {
|
||||
warn("cmap table has unsupported format: " + format);
|
||||
return {
|
||||
|
1
test/pdfs/.gitignore
vendored
1
test/pdfs/.gitignore
vendored
@ -18,6 +18,7 @@
|
||||
!issue2391-2.pdf
|
||||
!issue14046.pdf
|
||||
!issue7891_bc1.pdf
|
||||
!issue14881.pdf
|
||||
!issue3214.pdf
|
||||
!issue4665.pdf
|
||||
!issue4684.pdf
|
||||
|
BIN
test/pdfs/issue14881.pdf
Normal file
BIN
test/pdfs/issue14881.pdf
Normal file
Binary file not shown.
@ -4630,6 +4630,12 @@
|
||||
"password": "\u00E6\u00F8\u00E5",
|
||||
"about": "The password (æøå) is UTF8 encoded."
|
||||
},
|
||||
{ "id": "issue14881",
|
||||
"file": "pdfs/issue14881.pdf",
|
||||
"md5": "1aa3f2c7929eaf4502fcf6488ff31b5f",
|
||||
"rounds": 1,
|
||||
"type": "eq"
|
||||
},
|
||||
{ "id": "High-Pressure-Measurement-WP-001287",
|
||||
"file": "pdfs/High-Pressure-Measurement-WP-001287.pdf",
|
||||
"md5": "aeba7e47bbe50cbf08bb8bdff78fec8c",
|
||||
|
Loading…
Reference in New Issue
Block a user