Merge 9c9b37a58e39a84ae3938e7f5b361a9dec68a166 into 27bb5fb17392f2fd91ca3afcc35d124683087d95
This commit is contained in:
commit
e35b42c955
@ -4606,6 +4606,10 @@ class PartialEvaluator {
|
|||||||
if (typeof italicAngle !== "number") {
|
if (typeof italicAngle !== "number") {
|
||||||
italicAngle = 0;
|
italicAngle = 0;
|
||||||
}
|
}
|
||||||
|
let fontWeight = descriptor.get("FontWeight");
|
||||||
|
if (typeof fontWeight !== "number") {
|
||||||
|
fontWeight = 400;
|
||||||
|
}
|
||||||
|
|
||||||
const properties = {
|
const properties = {
|
||||||
type,
|
type,
|
||||||
@ -4630,6 +4634,7 @@ class PartialEvaluator {
|
|||||||
capHeight,
|
capHeight,
|
||||||
flags,
|
flags,
|
||||||
italicAngle,
|
italicAngle,
|
||||||
|
fontWeight,
|
||||||
isType3Font,
|
isType3Font,
|
||||||
cssFontInfo,
|
cssFontInfo,
|
||||||
scaleFactors: glyphScaleFactors,
|
scaleFactors: glyphScaleFactors,
|
||||||
|
|||||||
@ -1042,6 +1042,16 @@ class Font {
|
|||||||
this.fontMatrix = properties.fontMatrix;
|
this.fontMatrix = properties.fontMatrix;
|
||||||
this.bbox = properties.bbox;
|
this.bbox = properties.bbox;
|
||||||
this.defaultEncoding = properties.defaultEncoding;
|
this.defaultEncoding = properties.defaultEncoding;
|
||||||
|
if (typeof properties.fontWeight === "number") {
|
||||||
|
if (properties.fontWeight === 900) {
|
||||||
|
this.black = true;
|
||||||
|
} else if (properties.fontWeight >= 700) {
|
||||||
|
this.bold = true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (typeof properties.italicAngle === "number" && properties.italicAngle) {
|
||||||
|
this.italic = true;
|
||||||
|
}
|
||||||
|
|
||||||
this.toUnicode = properties.toUnicode;
|
this.toUnicode = properties.toUnicode;
|
||||||
this.toFontChar = [];
|
this.toFontChar = [];
|
||||||
|
|||||||
1
test/pdfs/.gitignore
vendored
1
test/pdfs/.gitignore
vendored
@ -753,3 +753,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
|
||||||
BIN
test/pdfs/translated_fonts_weight.pdf
Normal file
BIN
test/pdfs/translated_fonts_weight.pdf
Normal file
Binary file not shown.
@ -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 () {
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user