mirror of
https://github.com/mozilla/pdf.js.git
synced 2026-04-10 15:24:03 +02:00
Simplify compilation of font paths (PR 20346 follow-up)
Given that `CompiledFont.prototype.getPathJs` already returns data in the desired TypedArray format, we should be able to directly copy the font-path data which helps shorten the code a little bit (rather than the "manual" handling in PR 20346). To ensure that this keeps working as expected, a non-production `assert` is added to prevent any future surprises.
This commit is contained in:
parent
d38cddf2b6
commit
fa7ddbb9bc
@ -389,20 +389,15 @@ function compilePatternInfo(ir) {
|
||||
}
|
||||
|
||||
function compileFontPathInfo(path) {
|
||||
let data;
|
||||
let buffer;
|
||||
if (
|
||||
(typeof PDFJSDev !== "undefined" && PDFJSDev.test("MOZCENTRAL")) ||
|
||||
FeatureTest.isFloat16ArraySupported
|
||||
) {
|
||||
buffer = new ArrayBuffer(path.length * 2);
|
||||
data = new Float16Array(buffer);
|
||||
} else {
|
||||
buffer = new ArrayBuffer(path.length * 4);
|
||||
data = new Float32Array(buffer);
|
||||
if (typeof PDFJSDev === "undefined" || PDFJSDev.test("TESTING")) {
|
||||
assert(
|
||||
FeatureTest.isFloat16ArraySupported
|
||||
? path instanceof Float16Array
|
||||
: path instanceof Float32Array,
|
||||
"compileFontPathInfo: Unexpected path format."
|
||||
);
|
||||
}
|
||||
data.set(path);
|
||||
return buffer;
|
||||
return path.slice().buffer;
|
||||
}
|
||||
|
||||
export {
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user