Repository navigation
feat: Load font assets only through featureFontAssets - #10229
Merged
Merged
Conversation
Contributor
There was a problem hiding this comment.
🟡 Changes recommended
The font-assets exemption needs clarification because manually constructed MSDF fonts still require the feature’s shader chunks, while CanvasFont does not.
1 open issue
What changed in this PR
Moves font loading and MSDF shader chunks into featureFontAssets, continuing the engine’s tree-shakable feature migration.
Changes:
- Adds font registration with a texture-feature dependency and device-specific shader chunks.
- Updates exports, diagnostics, documentation, and 55 examples.
- Adds feature, export, and tree-shaking tests.
| File | Description |
|---|---|
| test/framework/features/feature-font-assets.test.mjs | Tests font feature installation and diagnostics. |
| test/bundles/treeshake.test.mjs | Checks font code and shader tree-shaking. |
| test/bundles/exports.test.mjs | Checks device-specific feature exports. |
| test/app.mjs | Uses the font feature in test setup. |
| src/scene/shader-lib/wgsl/collections/shader-chunks-wgsl.js | Removes MSDF chunks from core WGSL. |
| src/scene/shader-lib/wgsl/collections/msdf-chunks-wgsl.js | Adds the WGSL MSDF collection. |
| src/scene/shader-lib/glsl/collections/shader-chunks-glsl.js | Removes MSDF chunks from core GLSL. |
| src/scene/shader-lib/glsl/collections/msdf-chunks-glsl.js | Adds the GLSL MSDF collection. |
| src/index.js | Exports featureFontAssets. |
| src/index-webgpu.js | Exports the WebGPU variant. |
| src/index-webgl.js | Exports the WebGL variant. |
| src/framework/handlers/loader.js | Adds missing-font-feature guidance. |
| src/framework/handlers/font.js | Documents feature-based registration. |
| src/framework/features/feature-font-assets.js | Defines font registration and shader dependencies. |
| src/framework/features/constants.js | Adds the font feature identifier. |
| examples/src/examples/xr/xr-ui/example.mjs | Migrates font registration to the feature. |
| examples/src/examples/xr/xr-menu/example.mjs | Migrates font registration to the feature. |
| examples/src/examples/xr/vr-test-bed/example.mjs | Migrates font registration to the feature. |
| examples/src/examples/xr/ar-plane-detection/example.mjs | Migrates font registration to the feature. |
| examples/src/examples/xr/ar-mesh-detection/example.mjs | Migrates font registration to the feature. |
| examples/src/examples/user-interface/world-ui/example.mjs | Migrates font registration to the feature. |
| examples/src/examples/user-interface/world-to-screen/example.mjs | Migrates font registration to the feature. |
| examples/src/examples/user-interface/text/example.mjs | Migrates font registration to the feature. |
| examples/src/examples/user-interface/text-typewriter/example.mjs | Migrates font registration to the feature. |
| examples/src/examples/user-interface/text-markup/example.mjs | Migrates font registration to the feature. |
| examples/src/examples/user-interface/text-localization/example.mjs | Migrates font registration to the feature. |
| examples/src/examples/user-interface/text-justify/example.mjs | Migrates font registration to the feature. |
| examples/src/examples/user-interface/text-emojis/example.mjs | Migrates font registration to the feature. |
| examples/src/examples/user-interface/text-auto-font-size/example.mjs | Migrates font registration to the feature. |
| examples/src/examples/user-interface/scroll-view/example.mjs | Migrates font registration to the feature. |
| examples/src/examples/user-interface/screen-scaling/example.mjs | Migrates font registration to the feature. |
| examples/src/examples/user-interface/render-to-image/example.mjs | Migrates font registration to the feature. |
| examples/src/examples/user-interface/particle-system/example.mjs | Migrates font registration to the feature. |
| examples/src/examples/user-interface/panel/example.mjs | Migrates font registration to the feature. |
| examples/src/examples/user-interface/masking/example.mjs | Migrates font registration to the feature. |
| examples/src/examples/user-interface/layout-group/example.mjs | Migrates font registration to the feature. |
| examples/src/examples/user-interface/input-events/example.mjs | Migrates font registration to the feature. |
| examples/src/examples/user-interface/image-fit/example.mjs | Migrates font registration to the feature. |
| examples/src/examples/user-interface/drag-and-drop/example.mjs | Migrates font registration to the feature. |
| examples/src/examples/user-interface/custom-shader/example.mjs | Migrates font registration to the feature. |
| examples/src/examples/user-interface/common-widgets/example.mjs | Migrates font registration to the feature. |
| examples/src/examples/user-interface/buttons/example.mjs | Migrates font registration to the feature. |
| examples/src/examples/user-interface/anchors/example.mjs | Migrates font registration to the feature. |
| examples/src/examples/test/text-markup/example.mjs | Migrates font registration to the feature. |
| examples/src/examples/test/render-target-orientation/example.mjs | Migrates font registration to the feature. |
| examples/src/examples/test/opacity/example.mjs | Migrates font registration to the feature. |
| examples/src/examples/test/material-instance-overrides/example.mjs | Migrates font registration to the feature. |
| examples/src/examples/test/lightmap-sources/example.mjs | Migrates font registration to the feature. |
| examples/src/examples/test/environment-sources/example.mjs | Migrates font registration to the feature. |
| examples/src/examples/test/element-states/example.mjs | Migrates font registration to the feature. |
| examples/src/examples/test/element-colors/example.mjs | Migrates font registration to the feature. |
| examples/src/examples/test/alpha-to-coverage/example.mjs | Migrates font registration to the feature. |
| examples/src/examples/render-targets/multi-render-targets/example.mjs | Migrates font registration to the feature. |
| examples/src/examples/physics/raycast/example.mjs | Migrates font registration to the feature. |
| examples/src/examples/physics/falling-shapes/example.mjs | Migrates font registration to the feature. |
| examples/src/examples/physics/compound-collision/example.mjs | Migrates font registration to the feature. |
| examples/src/examples/misc/multi-app/example.mjs | Migrates font registration to the feature. |
| examples/src/examples/materials/material-transparency/example.mjs | Migrates font registration to the feature. |
| examples/src/examples/materials/material-translucent-specular/example.mjs | Migrates font registration to the feature. |
| examples/src/examples/materials/material-physical/example.mjs | Migrates font registration to the feature. |
| examples/src/examples/materials/material-anisotropic/example.mjs | Migrates font registration to the feature. |
| examples/src/examples/loaders/compressed-meshes/example.mjs | Migrates font registration to the feature. |
| examples/src/examples/graphics/asset-viewer/example.mjs | Migrates font registration to the feature. |
| examples/src/examples/gaussian-splatting/vr-lod/example.mjs | Uses the feature for HUD fonts. |
| examples/src/examples/demos/splash-one/example.mjs | Migrates font registration to the feature. |
| examples/src/examples/demos/catapult/example.mjs | Migrates font registration to the feature. |
| examples/src/examples/camera-frame/post-processing/example.mjs | Migrates font registration to the feature. |
| examples/src/examples/camera-frame/hdr/example.mjs | Migrates font registration to the feature. |
| examples/src/examples/camera-frame/ambient-occlusion/example.mjs | Migrates font registration to the feature. |
| examples/src/examples/animation/tween/example.mjs | Migrates font registration to the feature. |
Review effort: Balanced
Comment on lines
+56
to
+57
| * to load font assets. Fonts created in code, such as a {@link CanvasFont}, do not need it. It | ||
| * brings {@link featureTextureAssets}, which loads the texture pages of the fonts. |
Build size reportThis PR changes the size of the minified bundles.
Measured on a min build with identifier mangling off. In the shipped build esbuild renames identifiers by use count across the whole bundle, so any change reshuffles names file-wide and moves gzip/brotli by hundreds of bytes regardless of the actual change. Shipped bundle sizes with this PR
|
9 of 43 tasks
This branch was successfully deployed
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.

Font assets now load through a feature,
featureFontAssets, rather than by listingFontHandlerinAppOptions#resourceHandlers. The feature also brings the shader chunks of multi-channel signed distance field (MSDF) text, which the core shader chunks no longer include. Part of #10055, followingfeatureTextureAssets(#10228).Changes:
featureFontAssets, which registers the font handler, unless the application registered its own, and adds the MSDF text shader chunks. It requiresfeatureTextureAssets, which loads the texture pages of the fonts.msdfPSandmsdfVSchunks out of the core GLSL and WGSL chunk collections into the font assets feature, the same way area lights, shadows and particles bring their chunks.playcanvas/webglandplaycanvas/webgpuentry points bindfeatureFontAssetsto their device, so an application built from one does not bundle the MSDF chunks of the other shader language.featureFontAssetsis needed.CanvasFont, no longer bundles the font handler,Fontor the MSDF chunks.API Changes:
featureFontAssets.FontHandleris still exported, for its type, but it is registered byfeatureFontAssetsrather than listed inAppOptions#resourceHandlers.Examples:
FontHandlernow listfeatureFontAssetsin their features instead.