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,
|
info,
|
||||||
shadow,
|
shadow,
|
||||||
string32,
|
string32,
|
||||||
|
stringToBytes,
|
||||||
warn,
|
warn,
|
||||||
} from "../shared/util.js";
|
} from "../shared/util.js";
|
||||||
import { CFFCompiler, CFFParser } from "./cff_parser.js";
|
import { CFFCompiler, CFFParser } from "./cff_parser.js";
|
||||||
@ -741,13 +742,13 @@ function createCmapTable(glyphs, toUnicodeExtraMap, numGlyphs) {
|
|||||||
string32(format31012.length / 12); // nGroups
|
string32(format31012.length / 12); // nGroups
|
||||||
}
|
}
|
||||||
|
|
||||||
return (
|
return stringToBytes(
|
||||||
cmap +
|
cmap +
|
||||||
"\x00\x04" + // format
|
"\x00\x04" + // format
|
||||||
string16(format314.length + 4) + // length
|
string16(format314.length + 4) + // length
|
||||||
format314 +
|
format314 +
|
||||||
header31012 +
|
header31012 +
|
||||||
format31012
|
format31012
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -995,8 +996,7 @@ function createNameTable(name, proto) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
nameTable += strings.join("") + stringsUnicode.join("");
|
return stringToBytes(nameTable + strings.join("") + stringsUnicode.join(""));
|
||||||
return nameTable;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|||||||
@ -63,15 +63,7 @@ class OpenTypeFileBuilder {
|
|||||||
// write the table data first (mostly for checksum)
|
// write the table data first (mostly for checksum)
|
||||||
for (let i = 0; i < numTables; i++) {
|
for (let i = 0; i < numTables; i++) {
|
||||||
const table = tables.get(tablesNames[i]);
|
const table = tables.get(tablesNames[i]);
|
||||||
let tableOffset = tableOffsets[i];
|
file.set(table, 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;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// sfnt version (4 bytes)
|
// sfnt version (4 bytes)
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user