Skip to content

Offscreen canvases ignore fonts #49890

Done

Description

@jdm

pub(super) fn set_font(
&self,
cx: &mut JSContext,
canvas: Option<&HTMLCanvasElement>,
value: DOMString,
) {
let canvas = match canvas {
Some(element) => element,
None => return, // offscreen canvas doesn't have a placeholder canvas
};

OffscreenCanvasRenderingContext2D delegates to CanvasRenderingContext2D's SetFont implementation, which just calls this method and ends up passing a None value for the canvas.

Instead of an HTMLCanvasElement, we should pass a GlobalScope and CanvasRenderingContext2D can use self.global() instead. This should make a lot of tests in ./mach test-wpt tests/wpt/tests/html/canvas/offscreen/text start to pass (you will need to update the expectations).

Activity

  1. added
    E-less-complex
    A-content/canvas
    on Nov 13, 2026
  2. servo-highfive commented on Nov 13, 2026

    @servo-highfive

    Hi! If you have any questions regarding this issue, feel free to make a comment here, or ask it in Zulip.

    If you intend to work on this issue, then add @servo-highfive: assign me to your comment, and I'll assign this to you. 😄

    Please read and follow our AI Usage Policy:

    • You can use AI to help understand the code, make plans, and do code review.
    • You cannot post AI-generated code, comments, or PR descriptions.
  3. mwja commented on Nov 13, 2026

    @mwja
    Contributor

    I've already done a couple of issues on this repo, but canvas is still uncharted territory. I'll take it as I don't think I'm quite at the 'E-more-complex' level just yet

    @servo-highfive assign me

  4. added
    C-assigned
    on Nov 13, 2026
  5. servo-highfive commented on Nov 13, 2026

    @servo-highfive

    Hey @mwja! Thanks for your interest in working on this issue. It's now assigned to you!

  6. added a commit that references this issue on Nov 26, 2026
    2df3d02
  7. added a commit that references this issue on Nov 27, 2026
    7bf4973
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

A-content/canvasC-assignedE-less-complex

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions