Skip to content

CanvasRenderingContext2D.fontVariationSettings is not a standard property #1158

@louh

Description

@louh

Thank you for the new variable font support in #495! It helps a lot on my project where the same rendering code runs on both a browser (native canvas) and on the server with this module. With variable font support here, I no longer need to install both fixed and variable width versions of the same font.

One thing I really appreciate about your project is that the API generally follows the browser spec, and I’m hoping that continues to be a goal.

With that said, I'm concerned that the newly added CanvasRenderingContext2D.fontVariationSettings property isn’t part of the standard CanvasRenderingContext2D API. In the browser's implementation of context, font weight is passed through the font shorthand property, as referenced in the original issue, for example:

  ctx.font = `700 45px Roboto Mono`;

The parsing rules for the font property are defined here:
https://developer.mozilla.org/en-US/docs/Web/CSS/Reference/Properties/font

Right now, my browser-compatible code must be rewritten to use the non-standard fontVariationSettings property when run with this library. This breaks API parity with the browser and may confuse other developers who are already used to the browser canvas.

Would you consider revisiting this implementation to match the browser spec?

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions