Skip to content

Commit 9c9b37a

Browse files
Add tests for weight and italic extraction
1 parent b162611 commit 9c9b37a

File tree

3 files changed

+41
-0
lines changed

3 files changed

+41
-0
lines changed

test/pdfs/.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -752,3 +752,4 @@
752752
!bug1937438_af_from_latex.pdf
753753
!bug1937438_from_word.pdf
754754
!bug1937438_mml_from_latex.pdf
755+
!translated_fonts_weight.pdf
57.2 KB
Binary file not shown.

test/unit/api_spec.js

Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3309,6 +3309,46 @@ describe("api", function () {
33093309
await loadingTask.destroy();
33103310
});
33113311
});
3312+
3313+
describe("Fonts", function () {
3314+
it("set black/bold/italic properties to translated fonts", async function () {
3315+
const loadingTask = getDocument(
3316+
buildGetDocumentParams("translated_fonts_weight.pdf")
3317+
);
3318+
const pdfDoc = await loadingTask.promise;
3319+
const page = await pdfDoc.getPage(1);
3320+
await page.getOperatorList();
3321+
3322+
const fontsMap = Array.from(page.commonObjs);
3323+
const fonts = fontsMap.map(entry => entry[1]);
3324+
3325+
expect(fonts[0].black).toEqual(undefined);
3326+
expect(fonts[0].bold).toEqual(undefined);
3327+
expect(fonts[0].italic).toEqual(undefined);
3328+
3329+
expect(fonts[1].black).toEqual(undefined);
3330+
expect(fonts[1].bold).toEqual(true);
3331+
expect(fonts[1].italic).toEqual(undefined);
3332+
3333+
expect(fonts[2].black).toEqual(undefined);
3334+
expect(fonts[2].bold).toEqual(undefined);
3335+
expect(fonts[2].italic).toEqual(true);
3336+
3337+
expect(fonts[3].black).toEqual(undefined);
3338+
expect(fonts[3].bold).toEqual(true);
3339+
expect(fonts[3].italic).toEqual(true);
3340+
3341+
expect(fonts[4].black).toEqual(true);
3342+
expect(fonts[4].bold).toEqual(undefined);
3343+
expect(fonts[4].italic).toEqual(undefined);
3344+
3345+
expect(fonts[5].black).toEqual(true);
3346+
expect(fonts[5].bold).toEqual(undefined);
3347+
expect(fonts[5].italic).toEqual(true);
3348+
3349+
await loadingTask.destroy();
3350+
});
3351+
});
33123352
});
33133353

33143354
describe("Page", function () {

0 commit comments

Comments
 (0)