@react-pdf/font
Advanced tools
Comparing version 2.0.4 to 2.0.5
@@ -22,2 +22,19 @@ 'use strict'; | ||
var FONT_WEIGHTS = { | ||
thin: 100, | ||
hairline: 100, | ||
ultralight: 200, | ||
extralight: 200, | ||
light: 300, | ||
normal: 400, | ||
medium: 500, | ||
semibold: 600, | ||
demibold: 600, | ||
bold: 700, | ||
ultrabold: 800, | ||
extrabold: 800, | ||
heavy: 900, | ||
black: 900 | ||
}; | ||
var fetchFont = /*#__PURE__*/function () { | ||
@@ -62,2 +79,10 @@ var _ref = _asyncToGenerator__default['default']( /*#__PURE__*/_regeneratorRuntime__default['default'].mark(function _callee(src, options) { | ||
var resolveFontWeight = function resolveFontWeight(value) { | ||
return typeof value === 'string' ? FONT_WEIGHTS[value] : value; | ||
}; | ||
var sortByFontWeight = function sortByFontWeight(a, b) { | ||
return a.fontWeight - b.fontWeight; | ||
}; | ||
var FontSource = /*#__PURE__*/function () { | ||
@@ -164,3 +189,4 @@ function FontSource(src, fontFamily, fontStyle, fontWeight, options) { | ||
this.sources.push(new FontSource(src, this.family, fontStyle, fontWeight, options)); | ||
var numericFontWeight = resolveFontWeight(fontWeight); | ||
this.sources.push(new FontSource(src, this.family, fontStyle, numericFontWeight, options)); | ||
}; | ||
@@ -198,6 +224,6 @@ | ||
return s.fontWeight < fontWeight; | ||
}); | ||
}).sort(sortByFontWeight); | ||
var gt = styleSources.filter(function (s) { | ||
return s.fontWeight > fontWeight; | ||
}); | ||
}).sort(sortByFontWeight); | ||
@@ -204,0 +230,0 @@ if (fontWeight < 400) { |
@@ -16,2 +16,18 @@ 'use strict'; | ||
/* eslint-disable max-classes-per-file */ | ||
const FONT_WEIGHTS = { | ||
thin: 100, | ||
hairline: 100, | ||
ultralight: 200, | ||
extralight: 200, | ||
light: 300, | ||
normal: 400, | ||
medium: 500, | ||
semibold: 600, | ||
demibold: 600, | ||
bold: 700, | ||
ultrabold: 800, | ||
extrabold: 800, | ||
heavy: 900, | ||
black: 900 | ||
}; | ||
@@ -31,2 +47,8 @@ const fetchFont = async (src, options) => { | ||
const resolveFontWeight = value => { | ||
return typeof value === 'string' ? FONT_WEIGHTS[value] : value; | ||
}; | ||
const sortByFontWeight = (a, b) => a.fontWeight - b.fontWeight; | ||
class FontSource { | ||
@@ -88,3 +110,4 @@ constructor(src, fontFamily, fontStyle, fontWeight, options) { | ||
}) { | ||
this.sources.push(new FontSource(src, this.family, fontStyle, fontWeight, options)); | ||
const numericFontWeight = resolveFontWeight(fontWeight); | ||
this.sources.push(new FontSource(src, this.family, fontStyle, numericFontWeight, options)); | ||
} | ||
@@ -110,4 +133,4 @@ | ||
const lt = styleSources.filter(s => s.fontWeight < fontWeight); | ||
const gt = styleSources.filter(s => s.fontWeight > fontWeight); | ||
const lt = styleSources.filter(s => s.fontWeight < fontWeight).sort(sortByFontWeight); | ||
const gt = styleSources.filter(s => s.fontWeight > fontWeight).sort(sortByFontWeight); | ||
@@ -114,0 +137,0 @@ if (fontWeight < 400) { |
{ | ||
"name": "@react-pdf/font", | ||
"version": "2.0.4", | ||
"version": "2.0.5", | ||
"license": "MIT", | ||
@@ -18,3 +18,3 @@ "author": "Diego Muracciole <diegomuracciole@gmail.com>", | ||
"dependencies": { | ||
"@react-pdf/fontkit": "^2.0.2", | ||
"@react-pdf/fontkit": "^2.0.3", | ||
"@react-pdf/types": "^2.0.1", | ||
@@ -26,3 +26,4 @@ "cross-fetch": "^3.0.4", | ||
"lib" | ||
] | ||
], | ||
"gitHead": "09b1b0b45bcd7cecd2bbd340aee1b026db18815c" | ||
} |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
48349
7
494
Updated@react-pdf/fontkit@^2.0.3