Automattic / Automattic/node-canvas

Roboto Condensed won't load under Canvas v2

Open
#868 9 comments 0 reactions 0 assignees View on GitHub
Text & Fonts
Dominant language
JavaScript
Stars
10.7k
Forks
1.2k
Avg merge
4d 8h
Merged PRs (30d)
1

Description

Hi there; Working on a project that makes use of Canvas (v2), requiring the use of a custom font.
I'm successfully able to use Roboto and Roboto Mono just fine, however Roboto Condensed refuses to load. Both my friend and I cannot find anything wrong in terms of syntax, even swapping out the font file with something else to see if it works (it does), but I can't think of anything else to do than to report this here.

Might be a bug with Pango, being unable to load Roboto Condensed. I'm able to load the font file just fine into my OS however.

Font file in question is here, and my code usage follows.
https://drive.google.com/open?id=0B4plslC0TxcnSlpkWnRpZnB3aUE

```js
Canvas.registerFont(path.join(__dirname, "fonts", "Roboto-Regular.ttf"), { family: "Roboto" });
Canvas.registerFont(path.join(__dirname, "fonts", "RobotoCondensed-Regular.ttf"), { family: "Roboto Condensed" });
Canvas.registerFont(path.join(__dirname, "fonts", "RobotoMono-Light.ttf"), { family: "Roboto Mono" });
```

```js
ctx.textAlign = "right";
ctx.font = "15px 'Roboto Condensed'";
ctx.fillText("65%", 370, 100);
```

Contributor guide

No contributing guide indexed for this repository

Research direction

Start at the Canvas.registerFont entry point and reproduce the three font registrations and the ctx.font assignment shown in the issue, using the linked Roboto Condensed file. Compare its behavior with Roboto and Roboto Mono and investigate the font-loading path, including the suspected Pango interaction. Done means Roboto Condensed loads and renders through ctx.fillText.

Written by the indexing model from the issue text.

Assessment

Tech stack
javascript, node.js
Domain
computer-graphics
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Needs clarification
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.