@animax-js/animax-textra
v0.1.0-alpha.0
Published
AnimaX Textra text layout module compiled to WebAssembly (WASM)
Maintainers
Readme
@animax-js/animax-textra
Textra-based text layout module compiled to WebAssembly (WASM) for the AnimaX animation framework on the Web platform.
Installation
Install this package only when your AnimaX animation needs Textra text layout. Keep its version aligned with @animax-js/animax.
npm install @animax-js/animax@latest \
@animax-js/animax-textra@latestUsage
import { AnimaXViewElement } from '@animax-js/animax';
import type { AnimaXFontConfig } from '@animax-js/animax';
import { AnimaXTextraModuleUrl } from '@animax-js/animax-textra';
const fontCdn =
'https://example.com/fonts/';
const fontConfig: AnimaXFontConfig = {
defaultFamily: 'Noto Sans SC',
fonts: [
{
family: 'Noto Sans SC',
url: `${fontCdn}NotoSansSC-fallback.ttf`,
},
{
family: 'Noto Sans Thai',
url: `${fontCdn}NotoSansThai-Regular.ttf`,
},
{
family: 'Noto Emoji',
url: `${fontCdn}Noto-COLRv1.ttf`,
},
],
};
const [fontsLoaded, textraLoaded] = await Promise.all([
AnimaXViewElement.configureFonts(fontConfig),
AnimaXViewElement.loadTextraModule(AnimaXTextraModuleUrl),
]);
if (!fontsLoaded || !textraLoaded) {
throw new Error('Failed to load AnimaX Textra runtime');
}Load the module once before rendering animations that need Textra text layout. For precise multi-language fallback on Web, configure fonts from the core package with AnimaXViewElement.configureFonts(...) before mounting <animax-view>.
Font descriptors are intentionally minimal:
type AnimaXFontDescriptor = {
family: string;
url: string;
};Fallback order follows the order in fonts. defaultFamily marks the configured default font. aliases, roles, fallbackPriority, and fallbackOrder are not supported by the Web public API.
Package Contents
@animax-js/animax-textra/
└── out/
├── index.js
├── index.d.ts
└── lib/
└── animax-textra.wasmThe runtime side module name remains animax_textra.wasm; @animax-js/animax maps that name to this package URL when loadTextraModule() is called.
License
MIT
