mirror of
https://github.com/mozilla/pdf.js.git
synced 2026-10-04 06:18:00 +02:00
Compare commits
4
Commits
ef62f31f24
...
87a106c034
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
87a106c034 | ||
|
|
b5809f83d6 | ||
|
|
02aa7f5e91 | ||
|
|
f8e53e0e0c |
+1
-1
@@ -97,7 +97,6 @@ const EXPORT_DATA_PROPERTIES = [
|
||||
"italic",
|
||||
"loadedName",
|
||||
"missingFile",
|
||||
"name",
|
||||
"remeasure",
|
||||
"systemFontInfo",
|
||||
"vertical",
|
||||
@@ -112,6 +111,7 @@ const EXPORT_DATA_EXTRA_PROPERTIES = [
|
||||
"isMonospace",
|
||||
"isSerifFont",
|
||||
"isSymbolicFont",
|
||||
"name",
|
||||
"seacMap",
|
||||
"subtype",
|
||||
"toFontChar",
|
||||
|
||||
+1
-1
@@ -2787,7 +2787,7 @@ class WorkerTransport {
|
||||
break;
|
||||
}
|
||||
|
||||
const fontData = new FontInfo(exportedData);
|
||||
const fontData = new FontInfo(exportedData.buffer);
|
||||
const inspectFont =
|
||||
this._params.pdfBug && globalThis.FontInspector?.enabled
|
||||
? (font, url) => globalThis.FontInspector.fontAdded(font, url)
|
||||
|
||||
@@ -572,10 +572,6 @@ class FontFaceObject {
|
||||
return this.missingFile ? null : "font/opentype";
|
||||
}
|
||||
|
||||
get name() {
|
||||
return this.#fontData.name;
|
||||
}
|
||||
|
||||
get data() {
|
||||
return this.#fontData.data;
|
||||
}
|
||||
|
||||
@@ -110,12 +110,9 @@ class FontInfo {
|
||||
|
||||
#view;
|
||||
|
||||
constructor({ buffer, extra }) {
|
||||
constructor(buffer) {
|
||||
this.#buffer = buffer;
|
||||
this.#view = new DataView(buffer);
|
||||
if (extra) {
|
||||
Object.assign(this, extra);
|
||||
}
|
||||
}
|
||||
|
||||
#readBoolean(index) {
|
||||
@@ -237,10 +234,6 @@ class FontInfo {
|
||||
return shadow(this, "loadedName", this.#readString(1));
|
||||
}
|
||||
|
||||
get name() {
|
||||
return shadow(this, "name", this.#readString(2));
|
||||
}
|
||||
|
||||
#getBufferOffset(index) {
|
||||
let offset = FONT_INFO.OFFSET_STRINGS;
|
||||
// We need to move past any string-data first, hence the `<=` condition.
|
||||
|
||||
@@ -39,7 +39,7 @@ class FONT_INFO {
|
||||
|
||||
static numbers = ["ascent", "descent"];
|
||||
|
||||
static strings = ["fallbackName", "loadedName", "name"];
|
||||
static strings = ["fallbackName", "loadedName"];
|
||||
|
||||
static OFFSET_NUMBERS = Math.ceil((this.bools.length * 2) / 8);
|
||||
|
||||
|
||||
@@ -70,7 +70,6 @@ describe("obj_bin_transform", function () {
|
||||
fontMatrix: [1, 1, 1, 1, 1, 1],
|
||||
fallbackName: "string",
|
||||
loadedName: "string",
|
||||
name: "string",
|
||||
data: new Uint8Array([1, 2, 3, 4, 5, 6, 7, 8, 9, 10]),
|
||||
uselessProp: "something",
|
||||
};
|
||||
@@ -123,14 +122,14 @@ describe("obj_bin_transform", function () {
|
||||
|
||||
describe("FontInfo", function () {
|
||||
it("must roundtrip correctly for FontInfo", function () {
|
||||
let sizeEstimate = 67; // fixed offset until the strings
|
||||
let sizeEstimate = 57; // fixed offset until the strings
|
||||
const { encoder } = InfoUtils;
|
||||
sizeEstimate += 4 + 4 * (4 + encoder.encode("string").length);
|
||||
sizeEstimate += 4 + 4; // cssFontInfo and systemFontInfo
|
||||
sizeEstimate += 4 + fontInfo.data.length;
|
||||
const buffer = compileFontInfo(fontInfo);
|
||||
expect(buffer.byteLength).toEqual(sizeEstimate);
|
||||
const deserialized = new FontInfo({ buffer });
|
||||
const deserialized = new FontInfo(buffer);
|
||||
expect(deserialized.black).toBeTrue();
|
||||
expect(deserialized.bold).toBeTrue();
|
||||
expect(deserialized.disableFontFace).toBeTrue();
|
||||
@@ -147,7 +146,6 @@ describe("obj_bin_transform", function () {
|
||||
expect(deserialized.fontMatrix).toEqual([1, 1, 1, 1, 1, 1]);
|
||||
expect(deserialized.fallbackName).toEqual("string");
|
||||
expect(deserialized.loadedName).toEqual("string");
|
||||
expect(deserialized.name).toEqual("string");
|
||||
expect(Array.from(deserialized.data)).toEqual([
|
||||
1, 2, 3, 4, 5, 6, 7, 8, 9, 10,
|
||||
]);
|
||||
@@ -162,7 +160,7 @@ describe("obj_bin_transform", function () {
|
||||
cssFontInfo,
|
||||
systemFontInfo,
|
||||
});
|
||||
const deserialized = new FontInfo({ buffer });
|
||||
const deserialized = new FontInfo(buffer);
|
||||
expect(deserialized.cssFontInfo.fontWeight).toEqual("not a number");
|
||||
expect(deserialized.systemFontInfo.src).toEqual("source");
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user