SwiftDraw
SwiftDraw copied to clipboard
Regression: SVG(data:) returns nil for documents with ex/em width/height units (worked in 0.20.1, fails in 0.28.0)
Summary
SVG(data:) returns nil for any SVG whose root width/height attributes use ex or em units. These documents parsed fine in 0.20.1; px (and unitless) values work in both versions.
Minimal repro
import SwiftDraw
let ex = #"<svg xmlns="http://www.w3.org/2000/svg" width="2ex" height="1ex"><rect width="5" height="5"/></svg>"#
let em = #"<svg xmlns="http://www.w3.org/2000/svg" width="2em" height="1em"><rect width="5" height="5"/></svg>"#
let px = #"<svg xmlns="http://www.w3.org/2000/svg" width="2px" height="1px"><rect width="5" height="5"/></svg>"#
SVG(data: Data(ex.utf8)) // nil on 0.28.0 — parsed on 0.20.1
SVG(data: Data(em.utf8)) // nil on 0.28.0 — parsed on 0.20.1
SVG(data: Data(px.utf8)) // parses on both
Why it matters
MathJax v3 always emits ex units on its SVG output roots, e.g.
<svg style="vertical-align: -0.025ex;" xmlns="http://www.w3.org/2000/svg" width="1.294ex" height="1.025ex" role="img" …>
so every MathJax-generated SVG now fails to parse. Downstream, LaTeXSwiftUI renders equations via MathJaxSwift → SwiftDraw; once dependency resolution picks SwiftDraw ≥ 0.28, every equation silently renders blank. Pinning SwiftDraw to 0.20.1 restores rendering.
Environment
- SwiftDraw 0.28.0 (fails) vs 0.20.1 (works) — I haven't bisected the versions in between
- macOS 26.3, Xcode 26.6
Happy to test a fix or provide more samples.
Fixed in 0.28.1 release