Add font weight to font instance.

This commit is contained in:
Edoardo Cavazza 2025-10-01 19:35:15 +02:00 committed by GitHub
parent 7fa50712c9
commit 3fcb77a1a2
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
2 changed files with 7 additions and 0 deletions

View File

@ -4599,6 +4599,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,
@ -4623,6 +4627,7 @@ class PartialEvaluator {
capHeight, capHeight,
flags, flags,
italicAngle, italicAngle,
fontWeight,
isType3Font, isType3Font,
cssFontInfo, cssFontInfo,
scaleFactors: glyphScaleFactors, scaleFactors: glyphScaleFactors,

View File

@ -91,6 +91,7 @@ const EXPORT_DATA_PROPERTIES = [
"fallbackName", "fallbackName",
"fontExtraProperties", "fontExtraProperties",
"fontMatrix", "fontMatrix",
"fontWeight",
"isInvalidPDFjsFont", "isInvalidPDFjsFont",
"isType3Font", "isType3Font",
"italic", "italic",
@ -1036,6 +1037,7 @@ class Font {
this.descent = properties.descent / PDF_GLYPH_SPACE_UNITS; this.descent = properties.descent / PDF_GLYPH_SPACE_UNITS;
this.lineHeight = this.ascent - this.descent; this.lineHeight = this.ascent - this.descent;
this.fontMatrix = properties.fontMatrix; this.fontMatrix = properties.fontMatrix;
this.fontWeight = properties.fontWeight;
this.bbox = properties.bbox; this.bbox = properties.bbox;
this.defaultEncoding = properties.defaultEncoding; this.defaultEncoding = properties.defaultEncoding;