Skip to content

Conversation

@balsamiqMarco
Copy link

We need the text rendering capabilities of Pango (i.e. kerning), so we built node-canvas with 'with_pango' set to true. Problem is, that we use a custom TrueType font and it seems that node-canvas doesn't load it properly when using Pango.

The proposed change fixes the font loading step by calling FontConfig API.

Sample code:

var canvas = new Canvas(400,40);
var ctx = canvas.getContext('2d');
var Font = Canvas.Font;

var myFont = new Font('MyFont', '../fonts/pip.ttf');
myFont.addFace('../fonts/pipBold.ttf', 'bold');

// Do not call addFont when using Pango
//ctx.addFont(myFont);

ctx.font = "30px MyFont";
ctx.fillText("kerning enabled AVAVAVA", 2, 32);

@terrancesnyder
Copy link

+1

@jakeg
Copy link
Contributor

jakeg commented Dec 8, 2014

+1

Applying your change to src/FontFace.cc (as well as setting with_pango to 'true' in bindings.gyp) then running node-gyp rebuild seems to work for me. I'm using pango so as to have fallback fonts working.

@LinusU LinusU mentioned this pull request Sep 14, 2015
@LinusU
Copy link
Collaborator

LinusU commented Feb 10, 2016

Seems to be landed on master already 👍

@LinusU LinusU closed this Feb 10, 2016
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants