mirror of
https://github.com/mozilla/pdf.js.git
synced 2026-07-30 02:47:22 +02:00
Merge pull request #21214 from Snuffleupagus/CFFFont-improvements
Remove the `CompilerOutput.prototype.finalData` getter, and a few other font improvements (PR 21053 follow-up)
This commit is contained in:
commit
c196fa8196
@ -28,11 +28,12 @@ class CFFFont {
|
|||||||
this.seacs = this.cff.seacs;
|
this.seacs = this.cff.seacs;
|
||||||
try {
|
try {
|
||||||
this.data = compiler.compile();
|
this.data = compiler.compile();
|
||||||
} catch {
|
} catch (ex) {
|
||||||
warn("Failed to compile font " + properties.loadedName);
|
warn(`Failed to compile font "${properties.loadedName}": "${ex}".`);
|
||||||
// There may have just been an issue with the compiler, set the data
|
// There may have just been an issue with the compiler, set the data
|
||||||
// anyway and hope the font loaded.
|
// anyway and hope the font loaded.
|
||||||
this.data = file;
|
file.reset();
|
||||||
|
this.data = file.getBytes();
|
||||||
}
|
}
|
||||||
this._createBuiltInEncoding();
|
this._createBuiltInEncoding();
|
||||||
}
|
}
|
||||||
|
|||||||
@ -1400,12 +1400,6 @@ class CompilerOutput {
|
|||||||
return this.#buf.subarray(0, this.#pos);
|
return this.#buf.subarray(0, this.#pos);
|
||||||
}
|
}
|
||||||
|
|
||||||
get finalData() {
|
|
||||||
const data = this.#buf.slice(0, this.#pos);
|
|
||||||
this.#buf = null;
|
|
||||||
return data;
|
|
||||||
}
|
|
||||||
|
|
||||||
get length() {
|
get length() {
|
||||||
return this.#pos;
|
return this.#pos;
|
||||||
}
|
}
|
||||||
@ -1534,7 +1528,7 @@ class CFFCompiler {
|
|||||||
// the sanitizer will bail out. Add a dummy byte to avoid that.
|
// the sanitizer will bail out. Add a dummy byte to avoid that.
|
||||||
output.add([0]);
|
output.add([0]);
|
||||||
|
|
||||||
return output.finalData;
|
return output.data;
|
||||||
}
|
}
|
||||||
|
|
||||||
encodeNumber(value) {
|
encodeNumber(value) {
|
||||||
|
|||||||
@ -1519,6 +1519,12 @@ class Font {
|
|||||||
data[8] = data[9] = data[10] = data[11] = 0;
|
data[8] = data[9] = data[10] = data[11] = 0;
|
||||||
data[17] |= 0x20; // Set font optimized for cleartype flag.
|
data[17] |= 0x20; // Set font optimized for cleartype flag.
|
||||||
}
|
}
|
||||||
|
// The "CFF " table may be replaced completely, hence its data shouldn't
|
||||||
|
// need to be read and/or modified piecewise through a `DataView`.
|
||||||
|
const view =
|
||||||
|
tag === "CFF "
|
||||||
|
? null
|
||||||
|
: new DataView(data.buffer, data.byteOffset, data.byteLength);
|
||||||
|
|
||||||
return {
|
return {
|
||||||
tag,
|
tag,
|
||||||
@ -1526,7 +1532,7 @@ class Font {
|
|||||||
length,
|
length,
|
||||||
offset,
|
offset,
|
||||||
data,
|
data,
|
||||||
view: new DataView(data.buffer, data.byteOffset, data.byteLength),
|
view,
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user