1
0
Fork 0
mirror of https://github.com/mozilla/pdf.js.git synced 2025-04-24 09:08:07 +02:00

Send disableFontFace and fontExtraProperties as part of the exported font-data

These options are needed in the `FontFaceObject` class, and indirectly in `FontLoader` as well, which means that we currently need to pass them around manually in the API.
Given that the options are (obviously) available on the worker-thread, it's very easy to just provide them when creating `Font`-instances and then send them as part of the exported font-data. This way we're able to simplify the code (primarily on the main-thread), and note that `Font`-instances even had a `disableFontFace`-field already (but it wasn't properly initialized).
This commit is contained in:
Jonas Jenwald 2025-02-23 17:32:20 +01:00
parent ed64faa88c
commit 839e23f5c2
7 changed files with 120 additions and 94 deletions

View file

@ -16,17 +16,22 @@ describe("font_fpgm", function () {
const cMap = await CMapFactory.create({
encoding: Name.get("Identity-H"),
});
const font = new Font("font", new Stream(font2324), {
loadedName: "font",
type: "CIDFontType2",
differences: [],
defaultEncoding: [],
cMap,
toUnicode: new ToUnicodeMap([]),
xHeight: 0,
capHeight: 0,
italicAngle: 0,
});
const font = new Font(
"font",
new Stream(font2324),
{
loadedName: "font",
type: "CIDFontType2",
differences: [],
defaultEncoding: [],
cMap,
toUnicode: new ToUnicodeMap([]),
xHeight: 0,
capHeight: 0,
italicAngle: 0,
},
{}
);
const output = await ttx(font.data);
verifyTtxOutput(output);

View file

@ -17,16 +17,21 @@ describe("font_post", function () {
describe("OS/2 table removal on bad post table values", function () {
it("has invalid version number", async function () {
const font = new Font("font", new Stream(font2154), {
loadedName: "font",
type: "TrueType",
differences: [],
defaultEncoding: [],
toUnicode: new ToUnicodeMap([]),
xHeight: 0,
capHeight: 0,
italicAngle: 0,
});
const font = new Font(
"font",
new Stream(font2154),
{
loadedName: "font",
type: "TrueType",
differences: [],
defaultEncoding: [],
toUnicode: new ToUnicodeMap([]),
xHeight: 0,
capHeight: 0,
italicAngle: 0,
},
{}
);
const output = await ttx(font.data);
verifyTtxOutput(output);
@ -39,17 +44,22 @@ describe("font_post", function () {
const cMap = await CMapFactory.create({
encoding: Name.get("Identity-H"),
});
const font = new Font("font", new Stream(font1282), {
loadedName: "font",
type: "CIDFontType2",
differences: [],
defaultEncoding: [],
cMap,
toUnicode: new ToUnicodeMap([]),
xHeight: 0,
capHeight: 0,
italicAngle: 0,
});
const font = new Font(
"font",
new Stream(font1282),
{
loadedName: "font",
type: "CIDFontType2",
differences: [],
defaultEncoding: [],
cMap,
toUnicode: new ToUnicodeMap([]),
xHeight: 0,
capHeight: 0,
italicAngle: 0,
},
{}
);
const output = await ttx(font.data);
verifyTtxOutput(output);

View file

@ -24,17 +24,22 @@ describe("font_post", function () {
const cMap = await CMapFactory.create({
encoding: Name.get("Identity-H"),
});
const font = new Font("font", new Stream(font2109), {
loadedName: "font",
type: "CIDFontType2",
differences: [],
defaultEncoding: [],
cMap,
toUnicode: new ToUnicodeMap([]),
xHeight: 0,
capHeight: 0,
italicAngle: 0,
});
const font = new Font(
"font",
new Stream(font2109),
{
loadedName: "font",
type: "CIDFontType2",
differences: [],
defaultEncoding: [],
cMap,
toUnicode: new ToUnicodeMap([]),
xHeight: 0,
capHeight: 0,
italicAngle: 0,
},
{}
);
const output = await ttx(font.data);
verifyTtxOutput(output);
@ -42,16 +47,21 @@ describe("font_post", function () {
});
it("has invalid glyph name indexes", async function () {
const font = new Font("font", new Stream(font2189), {
loadedName: "font",
type: "TrueType",
differences: [],
defaultEncoding: [],
toUnicode: new ToUnicodeMap([]),
xHeight: 0,
capHeight: 0,
italicAngle: 0,
});
const font = new Font(
"font",
new Stream(font2189),
{
loadedName: "font",
type: "TrueType",
differences: [],
defaultEncoding: [],
toUnicode: new ToUnicodeMap([]),
xHeight: 0,
capHeight: 0,
italicAngle: 0,
},
{}
);
const output = await ttx(font.data);
verifyTtxOutput(output);
@ -59,16 +69,21 @@ describe("font_post", function () {
});
it("has right amount of glyphs specified", async function () {
const font = new Font("font", new Stream(font2374), {
loadedName: "font",
type: "TrueType",
differences: [],
defaultEncoding: [],
toUnicode: new ToUnicodeMap([]),
xHeight: 0,
capHeight: 0,
italicAngle: 0,
});
const font = new Font(
"font",
new Stream(font2374),
{
loadedName: "font",
type: "TrueType",
differences: [],
defaultEncoding: [],
toUnicode: new ToUnicodeMap([]),
xHeight: 0,
capHeight: 0,
italicAngle: 0,
},
{}
);
const output = await ttx(font.data);
verifyTtxOutput(output);