Skip to content

Commit f034321

Browse files
Set bold and italic flag translated font
1 parent 3234912 commit f034321

File tree

2 files changed

+15
-0
lines changed

2 files changed

+15
-0
lines changed

src/core/evaluator.js

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4599,6 +4599,10 @@ class PartialEvaluator {
45994599
if (typeof italicAngle !== "number") {
46004600
italicAngle = 0;
46014601
}
4602+
let fontWeight = descriptor.get("FontWeight");
4603+
if (typeof fontWeight !== "number") {
4604+
fontWeight = 400;
4605+
}
46024606

46034607
const properties = {
46044608
type,
@@ -4623,6 +4627,7 @@ class PartialEvaluator {
46234627
capHeight,
46244628
flags,
46254629
italicAngle,
4630+
fontWeight,
46264631
isType3Font,
46274632
cssFontInfo,
46284633
scaleFactors: glyphScaleFactors,

src/core/fonts.js

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1042,6 +1042,16 @@ class Font {
10421042
this.fontMatrix = properties.fontMatrix;
10431043
this.bbox = properties.bbox;
10441044
this.defaultEncoding = properties.defaultEncoding;
1045+
if (typeof properties.fontWeight === "number") {
1046+
if (properties.fontWeight === 900) {
1047+
this.black = true;
1048+
} else if (properties.fontWeight >= 700) {
1049+
this.bold = true;
1050+
}
1051+
}
1052+
if (typeof properties.italicAngle === "number" && properties.italicAngle) {
1053+
this.italic = true;
1054+
}
10451055

10461056
this.toUnicode = properties.toUnicode;
10471057
this.toFontChar = [];

0 commit comments

Comments
 (0)