Skip to content

Commit b162611

Browse files
Set bold and italic flag translated font
1 parent de7179f commit b162611

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
@@ -4606,6 +4606,10 @@ class PartialEvaluator {
46064606
if (typeof italicAngle !== "number") {
46074607
italicAngle = 0;
46084608
}
4609+
let fontWeight = descriptor.get("FontWeight");
4610+
if (typeof fontWeight !== "number") {
4611+
fontWeight = 400;
4612+
}
46094613

46104614
const properties = {
46114615
type,
@@ -4630,6 +4634,7 @@ class PartialEvaluator {
46304634
capHeight,
46314635
flags,
46324636
italicAngle,
4637+
fontWeight,
46334638
isType3Font,
46344639
cssFontInfo,
46354640
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)