-
Notifications
You must be signed in to change notification settings - Fork 1.2k
Text rendered with wrong font family #899
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Comments
Hello @chearon, thanks for your comment. The issue does not appear when using node-canvas 1.6.4 (see my first post). |
Does the exact string |
Hello @LinusU, this works in Chrome, Firefox, Opera and IE11. |
It works for me with v1.6.4 |
This is what I said in my very first post. It works with node-canvas 1.6.4 but it does NOT with node-canvas 1.6.5. That's why I switched back to version 1.6.4 for now. |
Whipped this together real quick to be able to test, but it seems like the output is identical 🤔 const parseCssFont = require('parse-css-font')
const unitsCss = require('units-css')
const weights = 'normal|bold|bolder|lighter|[1-9]00'
const styles = 'normal|italic|oblique'
const units = 'px|pt|pc|in|cm|mm|%'
const string = '\'([^\']+)\'|"([^"]+)"|[\\w-]+'
const fontre = new RegExp(
'^ *' +
'(?:(' + weights + ') *)?' +
'(?:(' + styles + ') *)?' +
'([\\d\\.]+)(' + units + ') *' +
'((?:' + string + ')( *, *(?:' + string + '))*)'
)
function oldParse (input) {
let font = {}
let captures = fontre.exec(input)
if (!captures) return
font.weight = captures[1] || 'normal'
font.style = captures[2] || 'normal'
font.size = parseFloat(captures[3])
font.unit = captures[4]
font.family = captures[5].replace(/["']/g, '').split(',')[0].trim()
return font
}
function newParse (input) {
const parsedFont = parseCssFont(input)
const parsedSize = unitsCss.parse(parsedFont.size)
return {
weight: parsedFont.weight,
style: parsedFont.style,
size: parsedSize.value,
unit: parsedSize.unit,
family: parsedFont.family[0]
}
}
console.log('OLD:')
console.log(oldParse(process.argv[2]))
console.log('NEW:')
console.log(newParse(process.argv[2])) output:
|
Any news on this? I tried out node-canvas 1.6.7 and the issue still exists. |
The text is rendered with the default sans-serif font family instead with the font defined with
ctx.font = "12px 'Marker SD'";
The issue appears since I upgraded to canvas 1.6.5. It works correctly with canvas version 1.6.4. Currently, I went back to version 1.6.4 as a workaround.
My environment
EDIT:
Maybe the same issue #868
The text was updated successfully, but these errors were encountered: