fix(platform): add loadFontFace to platform abstraction#805
Merged
Conversation
…owser support WebPlatformLegacy did not override font loading, so it inherited the FontFace JS constructor path from WebPlatform. On embedded/legacy browsers (QtWebKit, older WPEWebKit, some STB browsers) the FontFace API is absent or silently drops loaded fonts before they reach the canvas 2D rasteriser. Introduce Platform.loadFontFace(family, url) as the single extension point for canvas font loading: - WebPlatform: uses new FontFace().load() + document.fonts.add() (existing modern-browser behaviour, unchanged) - WebPlatformLegacy: injects a <style> @font-face rule with format hints (.ttf/.woff2/.woff/.otf) and eagerly triggers loading via document.fonts.load() where available; resolves immediately on browsers that lack the CSS Font Loading API so the browser can load the font lazily on first paint. CanvasFontHandler.loadFont() now delegates to stage.platform.loadFontFace() instead of constructing FontFace directly, keeping all browser-specific font loading logic inside the platform layer. Fixes font loading regression introduced in PR #746.
tuncayyildirtanuk
approved these changes
Jun 5, 2026
jfboeve
approved these changes
Jun 5, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
WebPlatformLegacy did not override font loading, so it inherited the FontFace JS constructor path from WebPlatform. On embedded/legacy browsers (QtWebKit, older WPEWebKit, some STB browsers) the FontFace API is absent or silently drops loaded fonts before they reach the canvas 2D rasteriser.
Introduce Platform.loadFontFace(family, url) as the single extension point for canvas font loading:
CanvasFontHandler.loadFont() now delegates to
stage.platform.loadFontFace() instead of constructing FontFace directly, keeping all browser-specific font loading logic inside the platform layer.
Fixes font loading regression introduced in PR #746.