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

CanvasRenderingContext2d.restore() does not restore font weight #1946

Closed
HackbrettXXX opened this issue Dec 10, 2021 · 2 comments · Fixed by #2187
Closed

CanvasRenderingContext2d.restore() does not restore font weight #1946

HackbrettXXX opened this issue Dec 10, 2021 · 2 comments · Fixed by #2187

Comments

@HackbrettXXX
Copy link

Issue

CanvasRenderingContext2d.restore() does not restore font weight.

Steps to Reproduce

var Canvas = require('canvas');
var canvas = Canvas.createCanvas(200, 200);
var ctx = canvas.getContext('2d');

ctx.font = 'normal 16px sans-serif';
ctx.save():
ctx.font = 'bold 16px sans-serif';
ctx.restore();
ctx.font === 'bold 16px sans-serif' // should be 'normal 16px sans-serif' now

Your Environment

  • canvas@2.8.0
  • node@16.4.2 on Windows 10
@LinusU
Copy link
Collaborator

LinusU commented Dec 11, 2021

I'm not able to reproduce this is in the browser. In fact, it seems like "bold" is always stripped 🤔

var canvas = document.createElement('canvas')
var ctx = canvas.getContext('2d')

ctx.font = '16px sans-serif'
console.log(ctx.font, 'should be "16px sans-serif"')
ctx.save()
ctx.font = 'bold 16px sans-serif'
console.log(ctx.font, 'should be "bold 16px sans-serif"')
ctx.restore()
console.log(ctx.font, 'should be "16px sans-serif"')

Screenshot 2021-12-11 at 12 25 58

@HackbrettXXX
Copy link
Author

In Chrome, this is logged (bold is returned):
image

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants