Compare commits

...
4 Commits
Author SHA1 Message Date
Tim van der Meij 87a106c034 Merge pull request #22059 from Snuffleupagus/FontInfo-rm-extra
Stop passing `extra` properties to the `FontInfo` class
2026-10-03 12:51:53 +02:00
Tim van der Meij b5809f83d6 Merge pull request #22057 from Snuffleupagus/rm-name-export
Stop exporting the Font `name` by default
2026-10-03 12:51:11 +02:00
Jonas Jenwald 02aa7f5e91 Stop passing extra properties to the FontInfo class
The `FontInfo` class doesn't use the `extra` properties for anything, and they are already exposed via the `FontFaceObject` instance which is how the debuggers access those properties.
2026-10-03 11:28:43 +02:00
Jonas Jenwald f8e53e0e0c Stop exporting the Font name by default
The only main-thread usage of this property is in the debuggers, hence we don't need to export it as part of the "compiled" font-info.
2026-10-02 23:14:11 +02:00
6 changed files with 7 additions and 20 deletions
+1 -1
View File
@@ -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
View File
@@ -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)
-4
View File
@@ -572,10 +572,6 @@ class FontFaceObject {
return this.missingFile ? null : "font/opentype";
}
get name() {
return this.#fontData.name;
}
get data() {
return this.#fontData.data;
}
+1 -8
View File
@@ -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.
+1 -1
View File
@@ -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);
+3 -5
View File
@@ -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");
});