PackageTrack
Sign in Get early access

usvg-tree

An SVG tree representation used by usvg.

0.38.0 4.1M downloads/mo #4970 most downloaded on crates.io RazrFalcon/resvg

What this package is like to depend on

Last release 3 years ago

no release in 18 months

Release timing varies

gaps range from 9 days to 3 months

Nearly every release is documented

notes for 9 of 9 stable releases

Nothing withdrawn

no release was ever pulled

3 years old

9 releases · first in 2023

0 releases in the last 12 months

see the full history below

Release timeline

9 releases · Mar 2023 to Jan 2024
2024 2025 2026
Release Pre-release

Releases

latest 9
  1. 0.38.0 21 Jan 2024
    Release notes

    Added

    • Each usvg::Node stores its absolute transform now. Node::abs_transform() executes in constant time now.
    • usvg::Tree::calculate_bounding_boxes to calculate all bounding boxes beforehand.
    • usvg::Node::bounding_box which returns a precalculated node's bounding box in object coordinates.
    • usvg::Node::abs_bounding_box which returns a precalculated node's bounding box in canvas coordinates.
    • usvg::Node::stroke_bounding_box which returns a precalculated node's bounding box, including stroke, in object coordinates.
    • usvg::Node::abs_stroke_bounding_box which returns a precalculated node's bounding box, including stroke, in canvas coordinates.
    • (c-api) resvg_get_node_stroke_bbox
    • usvg::Node::filters_bounding_box
    • usvg::Node::abs_filters_bounding_box
    • usvg::Tree::postprocess

    Changed

    • resvg renders usvg::Tree directly again. resvg::Tree is gone.
    • usvg no longer uses rctree for the nodes tree implementation. The tree is a regular enum now.
      • A caller no longer need to use the awkward *node.borrow().
      • No more panics on incorrect mutable Rc<RefCell> access.
      • Tree nodes respect tree's mutability rules. Before, one could mutate tree nodes when the tree itself is not mutable. Because Rc<RefCell> provides a shared mutable access.
    • Filters, clip paths, masks and patterns are stored as Rc<RefCell<T>> instead of Rc<T>. This is required for proper mutability since Node itself is no longer an Rc.
    • Rename usvg::NodeKind into usvg::Node.
    • Upgrade to Rust 2021 edition.

    Removed

    • resvg::Tree. No longer needed. resvg can render usvg::Tree directly once again.
    • rctree::Node methods. The Node API is completely different now.
    • usvg::NodeExt. No longer needed.
    • usvg::Node::calculate_bbox. Use usvg::Node::abs_bounding_box instead.
    • usvg::Tree::convert_text. Use usvg::Tree::postprocess instead.
    • usvg::TreeTextToPath trait. No longer needed.

    Fixed

    • Mark mask-type as a presentation attribute.
    • Do not show needless warnings when parsing some attributes.
    • feImage rendering with a non-default position. Thanks to @LaurenzV.
    Open source →
  2. 0.37.0 16 Dec 2023
    Release notes

    Added

    • usvg can write text back to SVG now. Thanks to @LaurenzV.
    • --preserve-text flag to the usvg CLI tool. Thanks to @LaurenzV.
    • Support transform-origin property. Thanks to @LaurenzV.
    • Support non-default markers order via paint-order. Previously, only fill and stroke could have been swapped. Thanks to @LaurenzV.
    • usvg_tree::Text::flattened that will contain a flattened/outlined text.
    • usvg_tree::Text::bounding_box. Will be set only after text flattening.
    • Optimize usvg_tree::NodeExt::abs_transform by storing absolute transforms in the tree instead of calculating them each time.

    Changed

    • usvg_tree::Text::positions was replaced with usvg_tree::Text::dx and usvg_tree::Text::dy.<br> usvg_tree::CharacterPosition::x and usvg_tree::CharacterPosition::y are gone. They were redundant and you should use usvg_tree::TextChunk::x and usvg_tree::TextChunk::y instead.
    • usvg_tree::LinearGradient::id and usvg_tree::RadialGradient::id are moved to usvg_tree::BaseGradient::id.
    • Do not generate element IDs during parsing. Previously, some elements like clipPaths and filters could have generated IDs, but it wasn't very reliable and mostly unnecessary. Renderer doesn't rely on them and usvg writer would generate them anyway.
    • Text-to-paths conversion via usvg_text_layout::Tree::convert_text no longer replaces original text elements with paths, but instead puts them into usvg_tree::Text::flattened.

    Removed

    • The transform field from usvg_tree::Path, usvg_tree::Image and usvg_tree::Text. Only usvg_tree::Group can have it.<br> It doesn't break anything, because those properties were never used before anyway.<br> Thanks to @LaurenzV.
    • usvg_tree::CharacterPosition
    • usvg_tree::Path::text_bbox. Use usvg_tree::Text::bounding_box instead.
    • usvg_text_layout::TextToPath trait for Text nodes. Only the whole tree can be converted at once.

    Fixed

    • Path object bounding box calculation. We were using point bounds instead of tight contour bounds. Was broken since v0.34
    • Convert text-to-paths in embedded SVGs as well. The one inside the Image node. Thanks to @LaurenzV.
    • Indirect text-decoration resolving in some cases. Thanks to @LaurenzV.
    • (usvg) Clip paths writing to SVG. Thanks to @LaurenzV.
    Open source →
  3. 0.36.0 05 Oct 2023
    Release notes

    Added

    • stroke-linejoin=miter-clip support. SVG2. Thanks to @torokati44.
    • Quoted FuncIRI support. Like fill="url('#gradient')". SVG2. Thanks to @romanzes.
    • Allow float values in rgb() and rgba() colors. SVG2. Thanks to @yisibl.
    • auto-start-reverse variant support to orient in markers. SVG2. Thanks to @EpicEricEE.

    Changed

    • Update dependencies.

    Fixed

    • Increase precision of the zero-scale transform check. Was rejecting some valid transforms before.
    • Panic when rendering a very specific text.
    • Greatly improve parsing performance when an SVG has a lot of references. Thanks to @wez.
    • (Qt API) Fix scaling factor calculation. Thanks to @missdeer.
    Open source →
  4. 0.35.0 28 Jun 2023
    Release notes

    Fixed

    • Panic when an element is completely outside the viewbox.

    Removed

    • FillPaint and StrokePaint filter inputs support. It's a mostly undocumented SVG feature that no one supports and no one uses. And it was adding a significant complexity to the codebase.
    • usvg::filter::Filter::fill_paint and usvg::filter::Filter::stroke_paint.
    • BackgroundImage, BackgroundAlpha, FillPaint and StrokePaint from usvg::filter::Input.
    • usvg::Group::filter_fill_paint and usvg::Group::filter_stroke_paint.
    Open source →
  5. 0.34.0 27 May 2023
    Release notes

    Changed

    • usvg uses tiny-skia geometry primitives now, including the Path container.<br> The main difference compared to the old usvg primitives is that tiny-skia uses f32 instead of f64. So while in theory we could loose some precision, in practice, f32 is used mainly as a storage type and precise math operations are still done using f64.<br> tiny-skia primitives are move robust, strict and have a nicer API.<br> More importantly, this change reduces the peak memory usages for SVGs with large paths (in terms of the number of segments). And removes the need to convert usvg::PathData into tiny-skia::Path before rendering. Which was just a useless reallocation.
    • All numbers are stored as f32 instead of f64 now.
    • Because we use tiny-skia::Path now, we allow quadratic curves as well. This includes usvg CLI output.
    • Because we allow quadratic curves now, text might render slightly differently (better?). This is because TrueType fonts contain only quadratic curves and we were converting them to cubic before.
    • usvg::Path no longer implements Default. Use usvg::Path::new instead.
    • Replace usvg::Rect with tiny_skia::NonZeroRect.
    • Replace usvg::PathBbox with tiny_skia::Rect.
    • Unlike the old usvg::PathBbox, tiny_skia::Rect allows both width and height to be zero. This is not an error.
    • usvg::filter::Turbulence::base_frequency was split into base_frequency_x and base_frequency_y.
    • usvg::NodeExt::calculate_bbox no longer includes stroke bbox.
    • (c-api) Use float instead of double everywhere.
    • The svgfilters crate was merged into resvg.
    • The rosvgtree crate was merged into usvg-parser.
    • usvg::Group::filter_fill moved to usvg::filter::Filter::fill_paint.
    • usvg::Group::filter_stroke moved to usvg::filter::Filter::stroke_paint.

    Remove

    • usvg::Point. Use tiny_skia::Point instead.
    • usvg::FuzzyEq. Use usvg::ApproxEqUlps instead.
    • usvg::FuzzyZero. Use usvg::ApproxZeroUlps instead.
    • (c-api) resvg_path_bbox. Use resvg_rect instead.
    • svgfilters crate.
    • rosvgtree crate.

    Fixed

    • Write transform on clipPath children in usvg SVG output.
    • Do not duplicate marker children IDs. Previously, each element resolved for a marker would preserve its ID. Affects only usvg SVG output and doesn't affect rendering.
    Open source →
  6. 0.33.0 17 May 2023
    Release notes

    Added

    • A new rendering algorithm.<br> When rendering isolated groups, aka layers, we have to know the layer bounding box beforehand, which is ridiculously hard in SVG.<br> Previously, resvg would simply use the canvas size for all the layers. Meaning that to render a 10x10px layer on a 1000x1000px canvas, we would have to allocate and then blend a 1000x1000px layer, which is just a waste of CPU cycles.<br> The new rendering algorithm is able to calculate layer bounding boxes, which dramatically improves performance when rendering a lot of tiny layers on a large canvas.<br> Moreover, it makes performance more linear with a canvas size increase.<br> The paris-30k.svg sample from google/forma is rendered 115 times faster on M1 Pro now. From ~33760ms down to ~290ms. 5269x3593px canvas.<br> If we restrict the canvas to 1000x1000px, which would contain only the actual paris-30k.svg content, then we're 13 times faster. From ~3252ms down to ~253ms.
    • resvg::Tree, aka a render tree, which is an even simpler version of usvg::Tree. usvg::Tree had to be converted into resvg::Tree before rendering now.

    Changed

    • Restructure the root directory. All crates are in the crates directory now.
    • Restructure tests. New directory structure and naming scheme.
    • Use resvg::Tree::render instead of resvg::render.
    • resvg's --export-area-drawing option uses calculated bounds instead of trimming excessive alpha now. It's faster, but can lead to a slightly different output.
    • (c-api) Removed fit_to argument from resvg_render.
    • (c-api) Removed fit_to argument from resvg_render_node.
    • usvg::ScreenSize moved to resvg.
    • usvg::ScreenRect moved to resvg.
    • Rename resvg::ScreenSize into resvg::IntSize.
    • Rename resvg::ScreenRect into resvg::IntRect.

    Removed

    • filter build feature from resvg. Filters are always enabled now.
    • resvg::FitTo
    • usvg::utils::view_box_to_transform_with_clip
    • usvg::Size::to_screen_size. Use resvg::IntSize::from_usvg instead.
    • usvg::Rect::to_screen_size. Use resvg::IntSize::from_usvg(rect.size()) instead.
    • usvg::Rect::to_screen_rect. Use resvg::IntRect::from_usvg instead.
    • (c-api) resvg_fit_to
    • (c-api) resvg_fit_to_type

    Fixed

    • Double quotes parsing in font-family.
    Open source →
  7. 0.32.0 23 Apr 2023
    Release notes

    Added

    • Clipping and masking is up to 20% faster.
    • mask-type property support. SVG2
    • usvg_tree::MaskType
    • usvg_tree::Mask::kind
    • (rosvgtree) New SVG 2 mask attributes.

    Changed

    • BackgroundImage and BackgroundAlpha filter inputs will produce the same output as SourceGraphic and SourceAlpha respectively.

    Removed

    • enable-background support. This feature was never supported by browsers and was deprecated in SVG 2. To my knowledge, only Batik has a good support of it. Also, it's a performance nightmare, which caused multiple issues in resvg already.
    • usvg_tree::EnableBackground
    • usvg_tree::Group::enable_background
    • usvg_tree::NodeExt::filter_background_start_node

    Fixed

    • Improve rectangular clipping anti-aliasing quality.
    • Mask's RGB to Luminance converter was ignoring premultiplied alpha.
    Open source →
  8. 0.31.0 10 Apr 2023
    Release notes

    Added

    • usvg::Tree::paint_servers
    • usvg::Tree::clip_paths
    • usvg::Tree::masks
    • usvg::Tree::filters
    • usvg::Node::subroots
    • (usvg) --coordinates-precision and --transforms-precision writing options. Thanks to @flxzt.

    Fixed

    • fill-opacity and stroke-opacity resolving.
    • Double transform when resolving symbol.
    • symbol clipping when its viewbox is the same as the document one.
    • (usvg) Deeply nested gradients, patterns, clip paths, masks and filters were ignored during SVG writing.
    • Missing text in nested clip paths and mask, text decoration patterns, filter inputs and feImage.
    Open source →
  9. 0.30.0 25 Mar 2023
    Release notes

    Added

    • Readd usvg CLI tool. Can be installed via cargo as before.

    Changed

    • Extract most usvg internals into new usvg-tree and usvg-parser crates. usvg-tree contains just the SVG tree and all the types. usvg-parser parsers SVG into usvg-tree. And usvg is just an umbrella crate now.
    • To use usvg::Tree::from* methods one should import the usvg::TreeParsing trait now.
    • No need to import usvg-text-layout manually anymore. It is part of usvg now.
    • rosvgtree no longer reexports svgtypes.
    • rosvgtree::Node::attribute returns just a string now.
    • rosvgtree::Node::find_attribute returns just a rosvgtree::Node now.
    • Rename usvg::Stretch into usvg::FontStretch.
    • Rename usvg::Style into usvg::FontStyle.
    • usvg::FitTo moved to resvg::FitTo.
    • usvg::IsDefault trait is private now.

    Removed

    • rosvgtree::FromValue. Due to Rust's orphan rules this trait is pretty useless.

    Fixed

    • Recursive markers detection.
    • Skip malformed transform attributes without skipping the whole element.
    • Clipping path rectangle calculation for nested svg elements. Thanks to @LaurenzV.
    • Panic when applying text-decoration on text with only one cluster. Thanks to @LaurenzV.
    • (Qt API) Image size wasn't initialized. Thanks to @missdeer.
    • resvg CLI allows files with XML DTD again.
    • (svgtypes) Handle implicit MoveTo after ClosePath segments.
    Open source →

Every package, every release, already written down.

The archive is open and free. Watching your own project is what we are building next.

Browse the archive