Skip to content

Support FontFace in workers #49892

Done
Done

Description

@jdm

Part of #29376.

Known issues:

[Exposed=(Window /*, Worker */), Pref="dom_fontface_enabled"] // TODO: Add support for FontFace in Workers.

let window = global.as_window(); // TODO: Support calling FontFace APIs from Worker

// TODO: FontFaceSet is not supported on Workers yet. The `as_window` call below should be
// replaced when we do support it.

[Exposed=(Window /*, Worker */)]

// FIXME: Figure out what to do for worker scopes.

// This will need adjustments once FontFaceSet is exposed to workers.

Activity

  1. added
    A-content/dom
    B-feature-tracking
    A-workers
    on Nov 13, 2026
  2. jdm commented on Nov 13, 2026

    @jdm
    MemberAuthor

    This makes tests like tests/wpt/tests/html/canvas/offscreen/manual/the-offscreen-canvas/offscreencanvas-worker-font-load-crash.html have errors/time out right now.

  3. rogerkorantenng commented on Nov 14, 2026

    @rogerkorantenng
    Contributor

    @jdm I tried this locally. FontFace and self.fonts don't exist in workers yet. Separately, an OffscreenCanvas without a <canvas> element ignores ctx.font, which covers every OffscreenCanvas in a worker. The font just stays "10px sans-serif":

    offscreencanvas-font

    I just saw that's already filed as #49890, which @mwja is working on. FontFace in workers can still be added without it, but a worker's canvas won't draw with a loaded font until #49890 is fixed.

    One more thing: workers share the page's font storage right now (worker.rs passes the page's font context), so fonts added in a worker would need to be kept separate from the page's.

  4. jdm commented on Nov 14, 2026

    @jdm
    MemberAuthor

    Yeah, I linked the webidl snippets where the worker exposure is commented out. Good point about the shared storage!

  5. added
    C-assigned
    on Nov 14, 2026
  6. servo-highfive commented on Nov 14, 2026

    @servo-highfive

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

  7. servo-highfive commented on Nov 14, 2026

    @servo-highfive

    It looks like this has already been assigned to someone. I'll leave the decision to a core contributor.

  8. rogerkorantenng commented on Nov 18, 2026

    @rogerkorantenng
    Contributor

    @jdm I split this into two PRs:

    1. script: Expose FontFace and FontFaceSet to workers #50046 exposes FontFace, FontFaceSet and self.fonts to workers. Workers use their own URL as the base, like Firefox. It doesn't store loaded fonts yet.
    2. fonts: Give workers their own font context #50049 gives dedicated and shared workers their own font context, so their fonts don't end up in the page's. Service workers already had a separate one.

    The first one is mostly small changes from window-only code to code that works for any global, and it fixes offscreencanvas-worker-font-load-crash.html. The second changes how workers are set up, so I kept it separate. The first doesn't store worker fonts, so nothing leaks into the page while only that one is merged.

  9. TimvdLippe commented on Nov 25, 2026

    @TimvdLippe
    Contributor

    Given the PRs have merged, I think we can close this as implemented?

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

Metadata

Metadata

Labels

A-content/domA-platform/fontsA-workersB-feature-trackingC-assigned

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions