-
-
Notifications
You must be signed in to change notification settings - Fork 934
web: Render device fonts using offscreen canvas #22254
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
base: master
Are you sure you want to change the base?
Conversation
|
Is it possible to switch to using the current text rendering if for the browser in use |
|
I think we can fall back to a regular canvas then. |
Values such as scale, ascent, descent, leading belong to the same category of font metrics, and conceptually it makes sense to represent them as one object, as they cannot be separated.
GlyphRef can both reference a &Glyph directly or a Ref<Glyph>, which is required to abstract away glyphs generated dynamically and cached. This is useful for e.g. rendering text on web using canvas.
This patch adds support for bitmap glyphs in addition to shape-based glyphs. Bitmap glyphs are useful for supporting device text rendered by the OS.
External font renderer provides/renders glyphs on demand, when core requests them. The logic of rendering glyphs can be external to core and is abstracted away so that frontends can provide their font renderers for device text.
CanvasFontRenderer is an implementation of a font renderer that can render glyphs using an offscreen canvas. This allows Ruffle to support device text properly on web.
Using this config option the user can select how device fonts should be rendered.
When DeviceFontRenderer::Canvas is set, no fonts will be set up, and instead CanvasFontRenderer will be used to render all device fonts.
49745c4 to
17bb5cc
Compare
This test verifies whether text using device fonts has proper metrics.
a97e588 to
1ec85d3
Compare
This test check whether device font glyphs are rendered inside proper bounds.
1ec85d3 to
a12f55c
Compare
|
I think this is ready for review. I added a TODO for the OffscreenCanvas compatibility issue, and I think it's fine to take care of it in follow-up PRs. |
Implement device fonts support on web using canvas font renderer. Device fonts are rendered on canvas and then used as a bitmap in Ruffle.
This PR is divided roughly into 2 parts:
This solves the current issue of missing device fonts on web—Ruffle currently uses the default, embedded Noto Sans font and allows providing custom fonts as device fonts. When the "canvas" font renderer is enabled, glyphs are rendered on an offscreen canvas by the device, and stored in a bitmap.
This is currently experimental, as some things may not work properly or are missing, such as:
This is being put behind a setting
deviceFontRendererwith valuecanvas(instead of the defaultembedded).