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

Unexpected font fallback strategy on Linux #2369

Open
1 task
UlyssesZh opened this issue Mar 27, 2024 · 0 comments
Open
1 task

Unexpected font fallback strategy on Linux #2369

UlyssesZh opened this issue Mar 27, 2024 · 0 comments

Comments

@UlyssesZh
Copy link

UlyssesZh commented Mar 27, 2024

Issue or Feature

Steps to Reproduce

npm install canvas
npm rebuild canvas --build-from-source # work around #2332
wget https://github.com/lxgw/LxgwWenKai/releases/download/v1.315/LXGWWenKai-Regular.ttf
vim test.mjs
// test.mjs
import { createCanvas, registerFont } from 'canvas';
import fs from 'fs';

const [_, __, family, font] = process.argv
console.log({family, font})
registerFont('LXGWWenKai-Regular.ttf', {family});
const canvas = createCanvas(128,128);
const ctx = canvas.getContext('2d');
ctx.font = `64px ${font}`;
ctx.fillText('test', 0, 64);

const data = canvas.toDataURL().replace(/^data:image\/\w+;base64,/, "");
fs.writeFileSync('out.png', data, 'base64');
node test.mjs test test && xdg-open out.png # good
node test.mjs test '"LXGW WenKai",Arial' && xdg-open out.png # good
node test.mjs test test,Arial && xdg-open out.png # uses Arial, bad
node test.mjs 'LXGW WenKai' '"LXGW WenKai",Arial' && xdg-open out.png # uses Arial, bad

Reproducible on Linux. Not reproducible on Windows.

Your Environment

  • Version of node-canvas (output of npm list canvas or yarn list canvas): 2.11.2
  • Environment (e.g. node 20.9.0 on macOS 14.1.1): Debian 12
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants