Skip to content

Load font file in FontConfig when using Pango #410

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

Closed
wants to merge 1 commit into from

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