Skip to content

Commit

Permalink
0.1.62
Browse files Browse the repository at this point in the history
  • Loading branch information
liborm85 committed Nov 3, 2019
1 parent 8cf3cdc commit 03519ac
Show file tree
Hide file tree
Showing 5 changed files with 34 additions and 25 deletions.
43 changes: 26 additions & 17 deletions build/pdfmake.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
/*! pdfmake v0.1.61, @license MIT, @link http://pdfmake.org */
/*! pdfmake v0.1.62, @license MIT, @link http://pdfmake.org */
(function webpackUniversalModuleDefinition(root, factory) {
if(typeof exports === 'object' && typeof module === 'object')
module.exports = factory();
Expand Down Expand Up @@ -19434,18 +19434,6 @@ var findFont = function (fonts, requiredFonts, defaultFont) {
return defaultFont;
};

var typeName = function (bold, italics) {
var type = 'normal';
if (bold && italics) {
type = 'bolditalics';
} else if (bold) {
type = 'bold';
} else if (italics) {
type = 'italics';
}
return type;
};

////////////////////////////////////////
// PdfPrinter

Expand Down Expand Up @@ -20025,9 +20013,15 @@ function renderSVG(svg, x, y, pdfKitDoc, fontProvider) {
fontOptions.fauxItalic = italic;

var fontsFamily = family.split(',').map(function (f) { return f.trim().replace(/('|")/g, ''); });
var font = findFont(fontProvider.fonts, fontsFamily, 'Roboto'); // TODO: default font from dd
var font = findFont(fontProvider.fonts, fontsFamily, svg.font || 'Roboto');

return fontProvider.fonts[font][typeName(bold, italic)];
var fontFile = fontProvider.getFontFile(font, bold, italic);
if (fontFile === null) {
var type = fontProvider.getFontType(bold, italic);
throw new Error('Font \'' + font + '\' in style \'' + type + '\' is not defined in the font section of the document definition.');
}

return fontFile;
};

getSvgToPDF()(pdfKitDoc, svg.svg, svg.x, svg.y, options);
Expand Down Expand Up @@ -59971,9 +59965,22 @@ function FontProvider(fontDescriptors, pdfKitDoc) {
}
}

FontProvider.prototype.provideFont = function (familyName, bold, italics) {
var type = typeName(bold, italics);
FontProvider.prototype.getFontType = function (bold, italics) {
return typeName(bold, italics);
}

FontProvider.prototype.getFontFile = function (familyName, bold, italics) {
var type = this.getFontType(bold, italics);
if (!this.fonts[familyName] || !this.fonts[familyName][type]) {
return null;
}

return this.fonts[familyName][type];
}

FontProvider.prototype.provideFont = function (familyName, bold, italics) {
var type = this.getFontType(bold, italics);
if (this.getFontFile(familyName, bold, italics) === null) {
throw new Error('Font \'' + familyName + '\' in style \'' + type + '\' is not defined in the font section of the document definition.');
}

Expand Down Expand Up @@ -61271,6 +61278,8 @@ DocMeasure.prototype.measureSVG = function (node) {

this.measureImageWithDimensions(node, dimensions);

node.font = this.styleStack.getProperty('font');

// scale SVG based on final dimension
node.svg = this.svgMeasure.writeDimensions(node.svg, {
width: node._width,
Expand Down
2 changes: 1 addition & 1 deletion build/pdfmake.js.map

Large diffs are not rendered by default.

10 changes: 5 additions & 5 deletions build/pdfmake.min.js

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion build/pdfmake.min.js.map

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "pdfmake",
"version": "0.1.61",
"version": "0.1.62",
"description": "Client/server side PDF printing in pure JavaScript",
"main": "src/printer.js",
"browser": "build/pdfmake.js",
Expand Down

0 comments on commit 03519ac

Please sign in to comment.