# Local changes to usvg 0.47.0
Upstream: [linebender/resvg](https://github.com/linebender/resvg/tree/3a0fdba53ccf2d346b54cc53ba7adf0ee60d0707/crates/usvg), revision `3a0fdba53ccf2d346b54cc53ba7adf0ee60d0707`. The crates.io archive SHA-256 is `d46cf96c5f498d36b7a9693bc6a7075c0bb9303189d61b2249b0dc3d309c07de`. Both upstream licences, headers and source metadata are retained. `Cargo.toml.orig` records the upstream manifest; the active manifest additionally uses cssparser and the common DOM, with the local XML provider shared by both packages.
The selected [CSS Display 3 Appendix B](https://www.w3.org/TR/2026/CRD-css-display-3-20260605/#unbox-svg) removes principal formatting for renderable SVG containers, text-content child elements and `use`, including its instantiated content. Other SVG elements, including a document SVG root and a text root, compute `contents` to `none`.
Conversion now classifies this display before producing geometry or effects. Boxless groups use transparent internal grouping, retain original native source/selector ancestry and computed attributes, and omit their own transforms, opacity, filters, clips and masks. Nested SVG elements do not establish a viewport. `use` retains instantiation and referenced viewports while ignoring its own positioning and size overrides. Conditional processing of `switch` remains before child conversion.
Text children omit their own position, rotation, length/path layout, baseline shift and decoration. Real ancestor decoration and inherited presentation properties remain. Native text collection preserves outer text-path flow, can hoist a path through a boxless span, and skips hidden subtrees. Explicit child inheritance still reads the original computed attributes. The existing inheritance path now includes `transform`.
Declaration and rule-list tokenization uses cssparser, preserving escaped identifiers, comments, case-insensitive property names, `!important` and malformed-declaration recovery. Display keyword tokens are decoded before interpretation. Selector parsing and matching of original XML source nodes now use the same native DOM engine as HTML; SimpleCss and its separate matcher are removed. A source-qualified XML view preserves original ancestry, namespaces, name/attribute case, namespace declarations, text, comments and processing instructions. It uses XML document semantics even for foreign HTML-namespace elements. The view and its match caches are built only when stylesheet selector rules exist. Namespace bindings stay local to each stylesheet and its header; the namespace prelude parser is shared with the style crate. Use expansion now creates a distinct shadow fragment for each referenced subtree in that same view. Original XML nodes remain the source for attributes and reference resolution; instance nodes carry separate selector identity, ancestry, siblings and host relationships. The existing native href and cycle resolver drives expansion once. A scoped guard restores the enclosing context across nested uses and errors, including text descendants. Pointer-based match caches are cleared before the graph grows. The native SVG depth budget remains 1024, independently of HTML declarative-shadow depth; cumulative cloned XML nodes use the existing one-million-node budget and return the native typed node-limit error before attaching a denied instance. Host rules use the common matcher, with normal outer declarations (including presentation attributes) taking precedence and inner important declarations overriding outer important declarations. The backend no longer gives unconditional priority to the first important declaration when later sorted declarations compete. These changes do not complete the remaining common cascade, stylesheet applicability, external use references or author-font integration.
`Tree::from_str_with_image_resolver` receives original image references, including data URLs, synchronously after native styling and visibility processing. The callback need not be thread-safe; existing `Options` and resolver APIs retain their types. The caller can preserve resource policy, byte/depth budgets and typed errors without preloading inactive definitions or effects. Its optional viewport overrides used dimensions without changing authored root attributes or selector matches. Existing conversion paths use the same converter with no callback or viewport override. The images crate caches resolved resources by their original references and the initial converted tree, reusing the latter at its original viewport.
`src/images/tests/svg_contents.rs` verifies geometry, original selectors, computed inheritance, text layout, use instances and referenced viewports, conditional selection, keyword syntax/recovery, hidden roots, resource non-acquisition, typed denials, data budgets and resized resource reuse. These regressions do not certify full SVG/CSS support or independent browser equivalence. Broader stylesheet-source, cascade and font integration remains part of the open standards programme.
CSS component-depth exhaustion from the shared cssparser provider is retained separately from recoverable malformed CSS. Both stylesheet and inline declarations carry that condition to `Error::CssComponentDepthLimit` before native conversion. The common style parser and SVG structural validation use the same named budget; an unused custom-property value cannot bypass it or silently remove its containing rule.
Source-cluster boundaries reuse the common fonts helper used by document shaping.
Every glyph retains its complete source cluster, byte identity and em advance.
Adjacent successful fallback prefixes can re-form ligatures when a later cluster
needs a different face. Initial family provenance remains distinct from an
explicitly named family, including names that coincide with the UA default.
`FontProvider` and `Tree::from_str_with_resolvers` accept a synchronous borrowed font provider alongside the image callback. Existing `Options` and its Send/Sync callback types retain their interfaces. Fallback receives the original family/style request; variation resolution can apply selected-face descriptors before explicit axis settings. The parser preserves that explicit provenance. Shaping and output spans use the same per-face coordinates; coordinate changes split spans while retaining decoration ordering. Missing clusters retain already covered glyphs, use source bidi/context when reshaped, respect the owning span, and group adjacent missing clusters only when they select the same fallback face. This preserves fallback ligatures and family priority without assuming identical glyph counts. The embedding images adapter provides stable job-local font identities and lazy byte access, including nested SVGs. Full native SVG text/cascade equivalence remains unverified.
The module is compiled inside `ferri-pdf` with the `text` feature always enabled. The
command-line binary, the SVG writer (`Tree::to_string` and `WriteOptions`) and the
system-font and memory-mapping features are removed. COLR painting reports unsupported
sweep gradients and blend modes through `log` instead of printing to standard output.
`font-weight` takes any whole number from 1 to 1000 (CSS Fonts 4 §2.2), not only multiples of
one hundred, so font matching receives the weight the document's cascade computed.
`feColorMatrix type="saturate"` keeps values above one, which oversaturate (Filter Effects 1
§9.6), instead of clamping them to one as SVG 1.1 did.
`direction: rtl` gives each text chunk a right-to-left bidi base level and swaps its `start` and
`end` anchors (SVG 2 §11.10.1.1, §11.10.2.4), so right-to-left documents place SVG text from its
anchor leftwards.
`transform-box: fill-box` and `stroke-box` on groups and shapes place `transform-origin` in the
element's object or stroke bounding box before its transform applies (CSS Transforms 1 §2);
other values keep the viewport as the reference.
`clip-path` takes CSS Shapes 1 §3 basic shapes and bare `<geometry-box>` keywords as well as
references (CSS Masking 1 §6.1). The document's computed basic shapes trace the outline in the
element's fill, stroke or view box, `stroke-box` by default, so SVG content and CSS boxes clip
alike.