본문으로 건너뛰기

SVG Import Mapping

SVG → Grida IR property mapping and TODO tracker.

Implementation: crates/grida-canvas/src/svg/ (uses usvg for pre-processing).

usvg simplifies the SVG DOM before we see it: <use> is resolved, CSS is computed, <defs> are inlined, transforms are flattened. Our mapping is from the usvg simplified tree, not raw SVG.

Elements

SVG Elementusvg TypeGrida IR NodeStatusNotes
<svg>Tree (root)Scene + InitialContainerviewBox → scene size
<g>GroupGroupNodeRecblend_mode, opacity, clip
<rect>, <circle>, <ellipse>, <line>, <polyline>, <polygon>PathPathNodeRecusvg pre-converts shapes to paths
<path>PathPathNodeRecFill + stroke + transform
<image>ImageImageNodeRecEmbedded raster data
<text>TextTextChunkTextSpanNodeRec⚠️Single-style spans; mixed-style partial
<clipPath>Group clipGroupNodeRec.clip⚠️Basic rectangular clips
<mask>MaskLayerMaskTypeLuminance + Alpha
<filter>--LayerEffects⚠️Not fully mapped from usvg
<marker>----Not mapped
<pattern>----No pattern fill IR
<symbol>(resolved by usvg)--Transparent — usvg inlines
<use>(resolved by usvg)--Transparent — usvg inlines
<defs>(resolved by usvg)--Transparent — usvg inlines
<foreignObject>----Not supported
<switch>----Not supported
SMIL animations----🚫Out of scope (static import)

Paint

SVG Featureusvg TypeGrida IRStatusNotes
Solid fill colorPaint::ColorPaint::Solid
Fill opacityFill.opacitypaint alpha
Fill ruleFillRuleFillRule (NonZero, EvenOdd)
Linear gradientPaint::LinearGradientPaint::LinearGradient
Radial gradientPaint::RadialGradientPaint::RadialGradient
Gradient stopsStop { offset, color, opacity }GradientColorStop
spreadMethod (pad)----Default
spreadMethod (reflect/repeat)----Only pad supported
Pattern fillPaint::Pattern--No IR equivalent

Stroke

SVG AttributeGrida IR FieldStatusNotes
stroke-widthStrokeWidth::Uniform
stroke-linecapStrokeCap (Butt, Round, Square)
stroke-linejoinStrokeJoin (Miter, MiterClip, Round, Bevel)
stroke-miterlimitStrokeMiterLimit
stroke-dasharrayStrokeDashArray
stroke-dashoffset--Not mapped
stroke-opacitypaint alpha

Transform

SVG FeatureGrida IRStatusNotes
transform (2D affine)AffineTransformusvg resolves nested transforms
3D transforms--2D only

Effects

SVG FeatureGrida IRStatusNotes
opacity (group/element)node.opacity
Blend modes (all 16)LayerBlendModeFull mapping
<feGaussianBlur>FeLayerBlur⚠️Not fully wired from usvg filter chain
<feDropShadow>FilterShadowEffect⚠️Not fully wired
<feColorMatrix>--No IR equivalent
<feComposite>--No IR equivalent
<feMorphology>--No IR equivalent
<feTurbulence>FeNoiseEffect⚠️IR exists, mapping incomplete

Text

SVG FeatureGrida IRStatusNotes
<text> contentTextSpanNodeRec.text
font-familyTextStyleRec.font_family
font-sizeTextStyleRec.font_size
font-weightTextStyleRec.font_weight
font-styleTextStyleRec.font_style_italic
text-anchorSVGTextAnchorStart, Middle, End
fill on textTextSpanNodeRec.fills
<textPath>--Text on path not supported
Multi-span mixed styles--⚠️Partial; each <tspan> becomes separate TextSpan
dominant-baseline--No baseline offset IR
letter-spacingTextLetterSpacing⚠️May not be mapped from usvg
word-spacingTextWordSpacing⚠️May not be mapped from usvg

IR Gaps (SVG features blocked by missing IR)

  1. Pattern fills -- <pattern> has no IR equivalent
  2. SVG filter primitives -- feColorMatrix, feComposite, feMorphology, etc.
  3. Gradient spread modes -- reflect/repeat not supported
  4. Text on path -- <textPath> needs path-follow layout
  5. Stroke dash offset -- stroke-dashoffset not in StrokeStyle