From b1626110162b6c540658874deba3c27def4c7777 Mon Sep 17 00:00:00 2001 From: Edoardo Cavazza Date: Thu, 2 Oct 2025 09:11:55 +0200 Subject: [PATCH] Set bold and italic flag translated font --- src/core/evaluator.js | 5 +++++ src/core/fonts.js | 10 ++++++++++ 2 files changed, 15 insertions(+) diff --git a/src/core/evaluator.js b/src/core/evaluator.js index 3e836ce16..ecef46302 100644 --- a/src/core/evaluator.js +++ b/src/core/evaluator.js @@ -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, diff --git a/src/core/fonts.js b/src/core/fonts.js index 97ea14c70..19f2c795e 100644 --- a/src/core/fonts.js +++ b/src/core/fonts.js @@ -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 = [];