|
1 |
| -/*! pdfmake v0.1.61, @license MIT, @link http://pdfmake.org */ |
| 1 | +/*! pdfmake v0.1.62, @license MIT, @link http://pdfmake.org */ |
2 | 2 | (function webpackUniversalModuleDefinition(root, factory) {
|
3 | 3 | if(typeof exports === 'object' && typeof module === 'object')
|
4 | 4 | module.exports = factory();
|
@@ -19434,18 +19434,6 @@ var findFont = function (fonts, requiredFonts, defaultFont) {
|
19434 | 19434 | return defaultFont;
|
19435 | 19435 | };
|
19436 | 19436 |
|
19437 |
| -var typeName = function (bold, italics) { |
19438 |
| - var type = 'normal'; |
19439 |
| - if (bold && italics) { |
19440 |
| - type = 'bolditalics'; |
19441 |
| - } else if (bold) { |
19442 |
| - type = 'bold'; |
19443 |
| - } else if (italics) { |
19444 |
| - type = 'italics'; |
19445 |
| - } |
19446 |
| - return type; |
19447 |
| -}; |
19448 |
| - |
19449 | 19437 | ////////////////////////////////////////
|
19450 | 19438 | // PdfPrinter
|
19451 | 19439 |
|
@@ -20025,9 +20013,15 @@ function renderSVG(svg, x, y, pdfKitDoc, fontProvider) {
|
20025 | 20013 | fontOptions.fauxItalic = italic;
|
20026 | 20014 |
|
20027 | 20015 | var fontsFamily = family.split(',').map(function (f) { return f.trim().replace(/('|")/g, ''); });
|
20028 |
| - var font = findFont(fontProvider.fonts, fontsFamily, 'Roboto'); // TODO: default font from dd |
| 20016 | + var font = findFont(fontProvider.fonts, fontsFamily, svg.font || 'Roboto'); |
20029 | 20017 |
|
20030 |
| - return fontProvider.fonts[font][typeName(bold, italic)]; |
| 20018 | + var fontFile = fontProvider.getFontFile(font, bold, italic); |
| 20019 | + if (fontFile === null) { |
| 20020 | + var type = fontProvider.getFontType(bold, italic); |
| 20021 | + throw new Error('Font \'' + font + '\' in style \'' + type + '\' is not defined in the font section of the document definition.'); |
| 20022 | + } |
| 20023 | + |
| 20024 | + return fontFile; |
20031 | 20025 | };
|
20032 | 20026 |
|
20033 | 20027 | getSvgToPDF()(pdfKitDoc, svg.svg, svg.x, svg.y, options);
|
@@ -59971,9 +59965,22 @@ function FontProvider(fontDescriptors, pdfKitDoc) {
|
59971 | 59965 | }
|
59972 | 59966 | }
|
59973 | 59967 |
|
59974 |
| -FontProvider.prototype.provideFont = function (familyName, bold, italics) { |
59975 |
| - var type = typeName(bold, italics); |
| 59968 | +FontProvider.prototype.getFontType = function (bold, italics) { |
| 59969 | + return typeName(bold, italics); |
| 59970 | +} |
| 59971 | + |
| 59972 | +FontProvider.prototype.getFontFile = function (familyName, bold, italics) { |
| 59973 | + var type = this.getFontType(bold, italics); |
59976 | 59974 | if (!this.fonts[familyName] || !this.fonts[familyName][type]) {
|
| 59975 | + return null; |
| 59976 | + } |
| 59977 | + |
| 59978 | + return this.fonts[familyName][type]; |
| 59979 | +} |
| 59980 | + |
| 59981 | +FontProvider.prototype.provideFont = function (familyName, bold, italics) { |
| 59982 | + var type = this.getFontType(bold, italics); |
| 59983 | + if (this.getFontFile(familyName, bold, italics) === null) { |
59977 | 59984 | throw new Error('Font \'' + familyName + '\' in style \'' + type + '\' is not defined in the font section of the document definition.');
|
59978 | 59985 | }
|
59979 | 59986 |
|
@@ -61271,6 +61278,8 @@ DocMeasure.prototype.measureSVG = function (node) {
|
61271 | 61278 |
|
61272 | 61279 | this.measureImageWithDimensions(node, dimensions);
|
61273 | 61280 |
|
| 61281 | + node.font = this.styleStack.getProperty('font'); |
| 61282 | + |
61274 | 61283 | // scale SVG based on final dimension
|
61275 | 61284 | node.svg = this.svgMeasure.writeDimensions(node.svg, {
|
61276 | 61285 | width: node._width,
|
|
0 commit comments