Add tests for weight and italic extraction

This commit is contained in:
Edoardo Cavazza 2025-10-30 16:15:13 +01:00
parent b162611016
commit 9c9b37a58e
3 changed files with 41 additions and 0 deletions

View File

@ -752,3 +752,4 @@
!bug1937438_af_from_latex.pdf !bug1937438_af_from_latex.pdf
!bug1937438_from_word.pdf !bug1937438_from_word.pdf
!bug1937438_mml_from_latex.pdf !bug1937438_mml_from_latex.pdf
!translated_fonts_weight.pdf

Binary file not shown.

View File

@ -3309,6 +3309,46 @@ describe("api", function () {
await loadingTask.destroy(); await loadingTask.destroy();
}); });
}); });
describe("Fonts", function () {
it("set black/bold/italic properties to translated fonts", async function () {
const loadingTask = getDocument(
buildGetDocumentParams("translated_fonts_weight.pdf")
);
const pdfDoc = await loadingTask.promise;
const page = await pdfDoc.getPage(1);
await page.getOperatorList();
const fontsMap = Array.from(page.commonObjs);
const fonts = fontsMap.map(entry => entry[1]);
expect(fonts[0].black).toEqual(undefined);
expect(fonts[0].bold).toEqual(undefined);
expect(fonts[0].italic).toEqual(undefined);
expect(fonts[1].black).toEqual(undefined);
expect(fonts[1].bold).toEqual(true);
expect(fonts[1].italic).toEqual(undefined);
expect(fonts[2].black).toEqual(undefined);
expect(fonts[2].bold).toEqual(undefined);
expect(fonts[2].italic).toEqual(true);
expect(fonts[3].black).toEqual(undefined);
expect(fonts[3].bold).toEqual(true);
expect(fonts[3].italic).toEqual(true);
expect(fonts[4].black).toEqual(true);
expect(fonts[4].bold).toEqual(undefined);
expect(fonts[4].italic).toEqual(undefined);
expect(fonts[5].black).toEqual(true);
expect(fonts[5].bold).toEqual(undefined);
expect(fonts[5].italic).toEqual(true);
await loadingTask.destroy();
});
});
}); });
describe("Page", function () { describe("Page", function () {