Skip to content
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

Can't load custom font in windows device #2408

Open
mahersalhani opened this issue Jul 17, 2024 · 2 comments
Open

Can't load custom font in windows device #2408

mahersalhani opened this issue Jul 17, 2024 · 2 comments

Comments

@mahersalhani
Copy link

Issue

Steps to Reproduce

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

@Andrekarma
Copy link

I do have the same problem, i talked about it here
#2285

@mahersalhani
Copy link
Author

I do have the same problem, i talked about it here #2285

I used The 2.10.2 vesion didn't work, it worked fine in my vps but not in my local device

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

No branches or pull requests

2 participants