-
Notifications
You must be signed in to change notification settings - Fork 1.2k
Open
Labels
Description
Issue or Feature
Cannot use two or more fonts that have the same preferredFamily, and the same style and weight, even though they are different fonts (they do have different family name, different postScriptName).
Example fonts:
- CopalStd-Solid
- fontFamily: Copal Std Solid
- fontSubfamily: Regular
- preferredFamily: Copal Std
- preferredSubfamily: Solid
- postScriptName: CopalStd-Solid
Can download the font here: http://fontsgeek.com/fonts/Copal-Std-Solid
- CopalStd-Decorated
- fontFamily: Copal Std Decorated
- fontSubfamily: Regular
- preferredFamily: Copal Std
- preferredSubfamily: Decorated
- postScriptName: CopalStd-Decorated
Can download the font here: http://fontsgeek.com/fonts/Copal-Std-Decorated
The above properties can be inspected by uploading the font(s) here: https://opentype.js.org/font-inspector.html and looking at the Naming table.
Steps to Reproduce
const Canvas = require('canvas')
const fs = require('fs');
Canvas.registerFont(__dirname + '/CopalStd-Decorated.otf', { family: 'Copal Std Decorated'});
Canvas.registerFont(__dirname + '/CopalStd-Solid.otf', { family: 'Copal Std Solid'});
const width = 800, height = 300;
const canvas = Canvas.createCanvas(width, height);
const ctx = canvas.getContext('2d');
ctx.fillStyle = '#FFFFFF';
ctx.fillRect(0, 0, width, height);
ctx.fillStyle = '#FF0000';
ctx.font = '50px Copal Std Solid'
ctx.fillText('Copal Std Solid', 50, 100)
ctx.font = '50px Copal Std Decorated'
ctx.fillText('Copal Std Decorated', 50, 200)
const out = fs.createWriteStream(__dirname + '/test.jpeg')
const stream = canvas.createJPEGStream()
stream.pipe(out)
out.on('finish', () => console.log('The JPEG file was created.'))
// etc.The result of this sample code is that both texts are rendered Copal Std Decorated (the font that was registered first), and it's impossible to render a text with Copal Std Solid (font that has the same preferredFamily, even though it is a different font).
Your Environment
- Version of node-canvas: 2.6.1
- Environment: node 10.15.3 on Linux
Reactions are currently unavailable

