We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
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
The script is executed without error . Unfortunately, the command
ctx.font = 'bold 72px fontOpenSans';
is ignored and it will set the default font and size .
When Canvas is set to PDF mode , the font is also not set , nor embedded in the PDF document .
Code-Snippet :
var Canvas = require('canvas') , Font = Canvas.Font , fs = require('fs');
if (!Font) { throw new Error('Need to compile with font support'); }
var fontOpenSans = new Font('fontOpenSans', 'OpenSans-Regular.ttf'); fontOpenSans.addFace('OpenSans-Bold.ttf', 'bold');
var canvas = new Canvas(600,800); var ctx = canvas.getContext('2d');
// Tell the ctx to use the font. ctx.addFont(fontOpenSans);
ctx.font = 'bold 72px fontOpenSans'; ctx.fillText('Open Sans Dummy-Text', 50, 80);
fs.writeFile('font.png', canvas.toBuffer());
The text was updated successfully, but these errors were encountered:
if you compiled with Pango, try ctx.font = 'bold 72px "Open Sans"';
ctx.font = 'bold 72px "Open Sans"';
Sorry, something went wrong.
It works!
Pango is the Problem.
Thank you.
No problem, you won't have to do that when I finish work on #715
No branches or pull requests
The script is executed without error . Unfortunately, the command
ctx.font = 'bold 72px fontOpenSans';
is ignored and it will set the default font and size .
When Canvas is set to PDF mode , the font is also not set , nor embedded in the PDF document .
System: Ubuntu Server 14.04 / NodeJS 5.6 / node-canvas 1.3.12
Code-Snippet :
var Canvas = require('canvas')
, Font = Canvas.Font
, fs = require('fs');
if (!Font) {
throw new Error('Need to compile with font support');
}
var fontOpenSans = new Font('fontOpenSans', 'OpenSans-Regular.ttf');
fontOpenSans.addFace('OpenSans-Bold.ttf', 'bold');
var canvas = new Canvas(600,800);
var ctx = canvas.getContext('2d');
// Tell the ctx to use the font.
ctx.addFont(fontOpenSans);
ctx.font = 'bold 72px fontOpenSans';
ctx.fillText('Open Sans Dummy-Text', 50, 80);
fs.writeFile('font.png', canvas.toBuffer());
The text was updated successfully, but these errors were encountered: