Responsive named styles and host-neutral plain/ruby text for
TurboWarp.
Responsibility
SVG Text is a text provider. It defines text styles, computes
host-neutral plain and ruby layout, creates and measures SVG text
skins when a renderer is used, and releases the skins it owns. Bubble
shape, tail, placement, portraits, and animation belong to the host
package.
Kamishibai DSL 4.0 bundle
In the combined runtime palette, click the documentation button below
the SVG Text member heading to return to this page.
The two bundled blocks are the same style-definition and sprite-text
blocks listed below; their member namespace and SVG Text icon identify
their origin. Host-only measurement and lifecycle operations remain in
the Composition API rather than the TurboWarp palette.
Installation
Install the Composition API with an exact version:
layoutRichText() accepts typed text and
ruby runs. Ruby base and reading rows have explicit
geometry and stay together as one wrapping and reveal unit. The layout
also returns deterministic plainText and
readingText projections.
maxWidth includes padding. Text wraps at grapheme
boundaries, but a ruby group is never split. An over-wide atomic ruby
group grows the layout and sets overflow: true. Use
plainText for visible/backlog text and choose explicitly
whether accessibility or speech uses plainText or
readingText. Renderer-backed
setRichText() and measureRichText() use the
same layout. No HTML, SVG markup, DOM node, URL, or event handler is
accepted as content.
Blocks
define text style [STYLE] background [BACKGROUND] text [TEXT_COLOR]
font [FONT] size [SIZE] align [ALIGN]
Defines or replaces a named text style. Alignment is left, center, or
right.
set this sprite text [TEXT] with style [STYLE]
Creates an SVG skin and applies it to the current sprite drawable.
measureText returns the maximum measured line width in
stage-relative pixels. The composition owns every skin passed to it.
Host-neutral text layout
createSvgTextLayoutComposition() requires no runtime,
renderer, skin, or drawable. Its synchronous
layoutText() receives a named style, text, and an
explicit renderer-native stage size. It returns deeply frozen
JSON-compatible data: overall width and height, the required
whitespace policy, normalized allowed style values, and each line's
text, width, horizontal position, and baseline.
Apply preserveWhitespace and assign text with
textContent. The API accepts and returns no SVG markup,
DOM nodes, event handlers, URLs, or foreignObject. The
layout-only and renderer-backed paths share the same calculation for
whitespace, font, size, alignment, line height, colors, placement,
width, and height.
Standalone named-style handoff
From 0.8.1, the stock extension exposes a frozen
getLayoutCapability(). Its layoutText()
resolves the exact named-style registry populated by the
define text style block and returns host-neutral data
without creating a skin or drawable. Redefining a style changes
subsequent layout results without exposing the mutable registry.
TurboWarp Bubble
can consume this package through its Text Capability. Bubble core does
not depend on SVG Text, and a different text provider can be injected.
Plain host-neutral layout first ships in 0.6.0, typed
ruby layout in 0.8.0, and the stock named-style handoff
in 0.8.1.
Bubble #59
should pin 0.9.0 when its default overlay consumes styles
defined through the standalone extension.
TM Kamishibai #636
and other ruby consumers can use
>=0.9.0 <1. Neither downstream package is imported
here.
The sprite changes to blue styled Hello, TurboWarp! text.
Run without sandboxを選んでAllowし、緑の旗を押します。
SVG Text: complete block reference
All 2 blocks are documented below, including compatibility blocks and
blocks available through optional features. Select a block to read its
behavior, arguments, default values, and menu choices. Each block has a
permanent link.
Static enum values are selected explicitly. New numeric edits must be
finite JSON number tokens; unfinished buffers cannot be saved. Unchanged
aliases, spaces and existing raw values are retained. Runtime style
names, assets and expressions are not evaluated or resolved by this
editor.