Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ project adheres to [Semantic Versioning](http://semver.org/).
### Added
* Support Node.js v12
### Fixed
* Fix object literal & arrow function syntax usage for IE.

2.4.1
==================
Expand Down
8 changes: 4 additions & 4 deletions browser.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ const parseFont = require('./lib/parse-font')
exports.parseFont = parseFont

exports.createCanvas = function (width, height) {
return Object.assign(document.createElement('canvas'), { width, height })
return Object.assign(document.createElement('canvas'), { width: width, height: height })
}

exports.createImageData = function (array, width, height) {
Expand All @@ -19,16 +19,16 @@ exports.createImageData = function (array, width, height) {
}

exports.loadImage = function (src, options) {
return new Promise((resolve, reject) => {
return new Promise(function (resolve, reject) {
const image = Object.assign(document.createElement('img'), options)

function cleanup () {
image.onload = null
image.onerror = null
}

image.onload = () => { cleanup(); resolve(image) }
image.onerror = () => { cleanup(); reject(new Error(`Failed to load the image "${src}"`)) }
image.onload = function () { cleanup(); resolve(image) }
image.onerror = function () { cleanup(); reject(new Error('Failed to load the image "' + src + '"')) }

image.src = src
})
Expand Down
8 changes: 4 additions & 4 deletions lib/parse-font.js
Original file line number Diff line number Diff line change
Expand Up @@ -14,10 +14,10 @@ const weights = 'bold|bolder|lighter|[1-9]00'
// [ [ <‘font-style’> || <font-variant-css21> || <‘font-weight’> || <‘font-stretch’> ]?
// <‘font-size’> [ / <‘line-height’> ]? <‘font-family’> ]
// https://drafts.csswg.org/css-fonts-3/#font-prop
const weightRe = new RegExp(`(${weights}) +`, 'i')
const styleRe = new RegExp(`(${styles}) +`, 'i')
const variantRe = new RegExp(`(${variants}) +`, 'i')
const stretchRe = new RegExp(`(${stretches}) +`, 'i')
const weightRe = new RegExp('(' + weights + ') +', 'i')
const styleRe = new RegExp('(' + styles + ') +', 'i')
const variantRe = new RegExp('(' + variants + ') +', 'i')
const stretchRe = new RegExp('(' + stretches + ') +', 'i')
const sizeFamilyRe = new RegExp(
'([\\d\\.]+)(' + units + ') *'
+ '((?:' + string + ')( *, *(?:' + string + '))*)')
Expand Down