You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
SVG <text> ignores textAnchor and fontSize in compositions #27
In a composition, <text textAnchor="middle" fontSize={48}> inside an <svg> draws at about 16 px, starting at x. The same attributes written in kebab-case work, so the SVG renderer is fine. The names are lowercased on the way in.
Repro
import{AbsoluteFill,Composition,registerRoot}from"raea";// three SVG <text> lines at x=320, anchored start, middle and end, at 48 px; a red line marks x=320functionClip(){return(<AbsoluteFillstyle={{background: "#ffffff"}}><svgwidth={640}height={360}viewBox="0 0 640 360"><linex1={320}y1={0}x2={320}y2={360}stroke="#ff0000"strokeWidth={2}/><textx={320}y={90}fontSize={48}textAnchor="start"fill="#000000">Start</text><textx={320}y={190}fontSize={48}textAnchor="middle"fill="#000000">Middle</text><textx={320}y={290}fontSize={48}textAnchor="end"fill="#000000">End</text></svg></AbsoluteFill>);}registerRoot(()=><Compositionid="t"component={Clip}width={640}height={360}fps={30}durationInFrames={1}/>);
raea render edit.tsx --frame 0 -o a.png on raea 0.1.0-canary.2 on Windows 11. The table gives the black ink's horizontal extent and height:
camelCase (textAnchor, fontSize)
kebab-case (text-anchor, font-size)
Start
x 321 to 352, 11 px tall
x 322 to 420, 35 px tall
Middle
x 321 to 365, 11 px tall
x 253 to 388, 34 px tall
End
x 321 to 346, 11 px tall
x 238 to 315, 34 px tall
Why, from reading main (cc729f2)
in_svg (systems/page/src/ops/attrs.rs:6-16) leaves out text, image and title on purpose, because those names also exist in HTML. For them the namespace must come from a $ns: "svg" prop.
Only sdk/ui's reconciler sets $ns. A composition's page walk (runtime/page/src/elements.rs:137, :148) doesn't track whether it is inside an <svg>. So <text> becomes an HTML-namespace element, and its attributes are lowercased to textanchor and fontsize, which usvg doesn't know.
sdk/ui/parity/cases/p15-media/svg-text.tsx tests exactly these attributes, but it runs through sdk/ui's path, which sets $ns. That's why parity passes.
On an update, systems/page/src/ops.rs:232 uses in_svg(kind) without looking at the node's namespace. So an animated fontSize on an SVG <text> is lowercased on every path, sdk/ui included.
Suggested fix
Track "inside an <svg>, not back in HTML under a <foreignObject>" during the walk, next to IN_3D in runtime/page/src/walk.rs, and set $ns: "svg" on text, image and title there. In ops.rs:232, also treat a node as SVG when its element is in the SVG namespace. That's about 15 lines. I'm happy to send it as a PR, with this repro and an animated fontSize case.
Thanks for the careful write-up and the measurements. The diagnosis is right: the composition walk in runtime/page never sets $ns: "svg", so text, image and title inside an <svg> become HTML elements and their attributes are lowercased. Creating a node honours $ns (systems/page/src/ops.rs:146), but the update at ops.rs:232 only looks at in_svg(kind), so an animated fontSize is lowercased on every path.
Yes please to the PR, with your repro and the animated fontSize case. Tracking "inside an <svg>, not under a <foreignObject>" beside IN_3D in walk.rs is the shape we'd want too. We'll review it when it's up.
Merged as ea50176 with your two commits in history. Thanks for the diagnosis and the fix, and sorry for the rebase churn: the crate limit we hit was our own doing that day. The fix is in from the next canary.
A follow-up to #35: 0032757 makes the regression test take its frames from the composition walk itself. Before, it gave the frame diff a hand-written frame with $ns already in it, so taking the walk's $ns insert out left every test passing. Now the test builds the React tree a composition leaves (a <text> in an <svg>, and a <title> under a <foreignObject>) and walks it on two frames. It checks that the <text> gets $ns, that the HTML <title> doesn't, and that an animated fontSize/textAnchor keeps its SVG names. Without the insert it fails. No render path changed, so there's no fps difference to report.
Thanks again for the report and the fix, @JimGHTB12.
Activity
shinyobjectz commentedon Nov 7, 2026
Thanks for the careful write-up and the measurements. The diagnosis is right: the composition walk in
runtime/pagenever sets$ns: "svg", sotext,imageandtitleinside an<svg>become HTML elements and their attributes are lowercased. Creating a node honours$ns(systems/page/src/ops.rs:146), but the update atops.rs:232only looks atin_svg(kind), so an animatedfontSizeis lowercased on every path.Yes please to the PR, with your repro and the animated
fontSizecase. Tracking "inside an<svg>, not under a<foreignObject>" besideIN_3Dinwalk.rsis the shape we'd want too. We'll review it when it's up.shinyobjectz#27: the regression test moves to raea-runtime-page, thro…
shinyobjectz#27: an SVG <text>, <image> and <title> keep their SVG at…
shinyobjectz#27: the regression test moves to raea-runtime-page, thro…
shinyobjectz commentedon Nov 8, 2026
Merged as ea50176 with your two commits in history. Thanks for the diagnosis and the fix, and sorry for the rebase churn: the crate limit we hit was our own doing that day. The fix is in from the next canary.
#35's test of an SVG <text>'s attribute names takes its frames from t…
shinyobjectz commentedon Nov 8, 2026
A follow-up to #35: 0032757 makes the regression test take its frames from the composition walk itself. Before, it gave the frame diff a hand-written frame with
$nsalready in it, so taking the walk's$nsinsert out left every test passing. Now the test builds the React tree a composition leaves (a<text>in an<svg>, and a<title>under a<foreignObject>) and walks it on two frames. It checks that the<text>gets$ns, that the HTML<title>doesn't, and that an animatedfontSize/textAnchorkeeps its SVG names. Without the insert it fails. No render path changed, so there's no fps difference to report.Thanks again for the report and the fix, @JimGHTB12.
Merge public PR shinyobjectz#35 from JimGHTB12: an SVG <text>, <image…
skills -> 9e0adfd: cli.md names raea render -o OUT.wav and --audio OU…