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

registerFont - One font completely dismisses another font #2484

Open
Materuilist opened this issue Jan 27, 2025 · 0 comments
Open

registerFont - One font completely dismisses another font #2484

Materuilist opened this issue Jan 27, 2025 · 0 comments

Comments

@Materuilist
Copy link

Hello, I have 3 custom font files, which contain the same font (Beach Pro Bold). I want to register them under 3 different families: Beach Pro Bold, Beach Pro Bold1, Beach Pro Bold2.
I register them properly, but when I am trying to render 3 different texts (one text per font family above), I see that Beach Pro Bold1 renders as the default system's font (screenshot).

    registerFont('./Beach Pro Bold_20250117181956_20250125071027.otf'), {
            family:  'Beach Pro Bold',
            weight: 700,
            style: 'normal'
     })
     registerFont('./Beach Pro Bold_20250119095142_20250125071053.otf'), {
            family:  'Beach Pro Bold1',
            weight: 700,
            style: 'normal'
     })
     registerFont('./Beach Pro Bold_20250119095811_20250125071118.otf'), {
            family:  'Beach Pro Bold2',
            weight: 700,
            style: 'normal'
     })

     const canvasNode = createCanvas(500, 500)
     const ctxNode = canvasNode.getContext('2d')

     ctxNode.font = '12px "Beach Pro Bold"';
     ctxNode.fillText('Beach Pro Bold', 250, 10);
     ctxNode.font = '12px "Beach Pro Bold1"';
     ctxNode.fillText('Beach Pro Bold1', 250, 30);
     ctxNode.font = '12px "Beach Pro Bold2"';
     ctxNode.fillText('Beach Pro Bold2', 250, 50);

Weird enough, if I remove Beach Pro Bold2, then Beach Pro Bold1 will render correctly.

System:
Node: 18.20.6
Canvas: 2.10.2
OS: built using Docker image node:18-alpine
Misc: It is just vanilla canvas project

Image

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

1 participant