mirror of
https://github.com/mozilla/pdf.js.git
synced 2026-06-22 16:05:56 +02:00
Convert the return value in createCmapTable and createNameTable to a TypedArray
Compared to the other TrueType table building functions, see previous patches, these ones are not trivial to convert to use TypedArrays properly. However, in order to simplify the `OpenTypeFileBuilder` implementation a little bit we can at least have these functions return TypedArray data.
This commit is contained in:
parent
e8ed6c6e24
commit
634ce3c163
@ -21,6 +21,7 @@ import {
|
||||
info,
|
||||
shadow,
|
||||
string32,
|
||||
stringToBytes,
|
||||
warn,
|
||||
} from "../shared/util.js";
|
||||
import { CFFCompiler, CFFParser } from "./cff_parser.js";
|
||||
@ -741,13 +742,13 @@ function createCmapTable(glyphs, toUnicodeExtraMap, numGlyphs) {
|
||||
string32(format31012.length / 12); // nGroups
|
||||
}
|
||||
|
||||
return (
|
||||
return stringToBytes(
|
||||
cmap +
|
||||
"\x00\x04" + // format
|
||||
string16(format314.length + 4) + // length
|
||||
format314 +
|
||||
header31012 +
|
||||
format31012
|
||||
"\x00\x04" + // format
|
||||
string16(format314.length + 4) + // length
|
||||
format314 +
|
||||
header31012 +
|
||||
format31012
|
||||
);
|
||||
}
|
||||
|
||||
@ -995,8 +996,7 @@ function createNameTable(name, proto) {
|
||||
}
|
||||
}
|
||||
|
||||
nameTable += strings.join("") + stringsUnicode.join("");
|
||||
return nameTable;
|
||||
return stringToBytes(nameTable + strings.join("") + stringsUnicode.join(""));
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@ -63,15 +63,7 @@ class OpenTypeFileBuilder {
|
||||
// write the table data first (mostly for checksum)
|
||||
for (let i = 0; i < numTables; i++) {
|
||||
const table = tables.get(tablesNames[i]);
|
||||
let tableOffset = tableOffsets[i];
|
||||
|
||||
if (table instanceof Uint8Array) {
|
||||
file.set(table, tableOffset);
|
||||
} else if (typeof table === "string") {
|
||||
for (let j = 0, jj = table.length; j < jj; j++) {
|
||||
file[tableOffset++] = table.charCodeAt(j) & 0xff;
|
||||
}
|
||||
}
|
||||
file.set(table, tableOffsets[i]);
|
||||
}
|
||||
|
||||
// sfnt version (4 bytes)
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user