Automattic / Automattic/node-canvas

Can't load custom font in windows device

Open
#2,408 2 comments 1 reaction 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

## Issue

## Steps to Reproduce

```js
const { createCanvas, registerFont } = require("canvas");
const path = require("path");
const fs = require("fs");

const fontPath = path.join(__dirname, "Fancy Thread DEMO 400.ttf");
console.log(`Loading font from: ${fontPath}`);

if (fs.existsSync(fontPath)) {
registerFont(fontPath, { family: "CustomFont" });
console.log("Font registered successfully");
} else {
console.error("Font file does not exist");
}

const canvas = createCanvas(800, 600);
const ctx = canvas.getContext("2d");

ctx.font = '48px "CustomFont"';
ctx.fillText("Hello, world!", 50, 100);

const buffer = canvas.toBuffer("image/png");
fs.writeFileSync("output.png", buffer);
console.log("Image saved as output.png");
```

## Your Environment
* Environment (e.g. node 20.9.0 on win 11):
* "canvas": "^2.11.2",

I getting this message error
(process:3048): Pango-WARNING **: 19:14:44.535: couldn't load font "Fancy Thread DEMO Not-Rotated 48px", falling back to "Sans Not-Rotated 48px", expect ugly output.
I can't load custom font
I tried in vps it worked the error only in windows

Contributor guide

No contributing guide indexed for this repository

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.