Set bold and italic flag translated font

This commit is contained in:
Edoardo Cavazza 2025-10-02 09:11:55 +02:00
parent de7179fd74
commit b162611016
2 changed files with 15 additions and 0 deletions

View File

@ -4606,6 +4606,10 @@ class PartialEvaluator {
if (typeof italicAngle !== "number") {
italicAngle = 0;
}
let fontWeight = descriptor.get("FontWeight");
if (typeof fontWeight !== "number") {
fontWeight = 400;
}
const properties = {
type,
@ -4630,6 +4634,7 @@ class PartialEvaluator {
capHeight,
flags,
italicAngle,
fontWeight,
isType3Font,
cssFontInfo,
scaleFactors: glyphScaleFactors,

View File

@ -1042,6 +1042,16 @@ class Font {
this.fontMatrix = properties.fontMatrix;
this.bbox = properties.bbox;
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.toFontChar = [];