@pdfme/pdf-lib 6.1.13-dev.31 → 6.1.13-dev.35
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/index.js +30 -5
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -17171,7 +17171,8 @@ var runnersToPage = (page, options) => ({
|
|
|
17171
17171
|
const isBold = style.fontWeight === "bold" || Number(style.fontWeight) >= 700;
|
|
17172
17172
|
const isItalic = style.fontStyle === "italic";
|
|
17173
17173
|
const getFont = (bold, italic, family) => fonts[family + (bold ? "_bold" : "") + (italic ? "_italic" : "")];
|
|
17174
|
-
|
|
17174
|
+
const matchingFontFamily = Object.keys(fonts).find((fontFamily) => fontFamily.startsWith(family));
|
|
17175
|
+
return getFont(isBold, isItalic, family) || getFont(isBold, false, family) || getFont(false, isItalic, family) || getFont(false, false, family) || (matchingFontFamily ? fonts[matchingFontFamily] : void 0);
|
|
17175
17176
|
}
|
|
17176
17177
|
const font = options.fonts && getBestFont(element.svgAttributes, options.fonts);
|
|
17177
17178
|
const textWidth = (font || page.getFont()[0]).widthOfTextAtSize(text, fontSize);
|
|
@@ -17290,6 +17291,33 @@ var parseStyles = (style) => {
|
|
|
17290
17291
|
}
|
|
17291
17292
|
return css;
|
|
17292
17293
|
};
|
|
17294
|
+
var stripImportantSuffix = (value) => {
|
|
17295
|
+
const suffix = "!important";
|
|
17296
|
+
const trimmed = value.trim();
|
|
17297
|
+
return trimmed.toLowerCase().endsWith(suffix) ? trimmed.slice(0, -10).trimEnd() : trimmed;
|
|
17298
|
+
};
|
|
17299
|
+
var splitFontFamilies = (fontFamily) => {
|
|
17300
|
+
const families = [];
|
|
17301
|
+
let current = "";
|
|
17302
|
+
let quote;
|
|
17303
|
+
for (const char of fontFamily) {
|
|
17304
|
+
if ((char === "\"" || char === "'") && (!quote || quote === char)) {
|
|
17305
|
+
quote = quote ? void 0 : char;
|
|
17306
|
+
continue;
|
|
17307
|
+
}
|
|
17308
|
+
if (char === "," && !quote) {
|
|
17309
|
+
if (current.trim()) families.push(current.trim());
|
|
17310
|
+
current = "";
|
|
17311
|
+
continue;
|
|
17312
|
+
}
|
|
17313
|
+
current += char;
|
|
17314
|
+
}
|
|
17315
|
+
if (current.trim()) families.push(current.trim());
|
|
17316
|
+
return families.map(stripImportantSuffix).filter(Boolean);
|
|
17317
|
+
};
|
|
17318
|
+
var normalizeFontFamily = (fontFamily) => {
|
|
17319
|
+
return splitFontFamilies(fontFamily)[0] || fontFamily.trim();
|
|
17320
|
+
};
|
|
17293
17321
|
var parseColor = (color, inherited) => {
|
|
17294
17322
|
if (!color || color.length === 0) return void 0;
|
|
17295
17323
|
if (["none", "transparent"].includes(color)) return void 0;
|
|
@@ -17407,10 +17435,7 @@ var parseAttributes = (element, inherited, matrix) => {
|
|
|
17407
17435
|
newMatrix = combineTransformation(newMatrix, "scale", [1, -1]);
|
|
17408
17436
|
svgAttributes.d = attributes.d;
|
|
17409
17437
|
}
|
|
17410
|
-
if (newInherited.fontFamily)
|
|
17411
|
-
const inner = newInherited.fontFamily.match(/^"(.*?)"|^'(.*?)'/);
|
|
17412
|
-
if (inner) newInherited.fontFamily = inner[1] || inner[2];
|
|
17413
|
-
}
|
|
17438
|
+
if (newInherited.fontFamily) newInherited.fontFamily = normalizeFontFamily(newInherited.fontFamily);
|
|
17414
17439
|
if (newInherited.strokeWidth) svgAttributes.strokeWidth = newInherited.strokeWidth;
|
|
17415
17440
|
return {
|
|
17416
17441
|
inherited: newInherited,
|