pax_global_header 0000666 0000000 0000000 00000000064 14675720665 0014534 g ustar 00root root 0000000 0000000 52 comment=ebb3984ef00afd9dc0b493a38f5b163baa41c4d5
resvg-0.44.0/ 0000775 0000000 0000000 00000000000 14675720665 0012747 5 ustar 00root root 0000000 0000000 resvg-0.44.0/.github/ 0000775 0000000 0000000 00000000000 14675720665 0014307 5 ustar 00root root 0000000 0000000 resvg-0.44.0/.github/chart-svg2.svg 0000664 0000000 0000000 00000006315 14675720665 0017015 0 ustar 00root root 0000000 0000000
resvg-0.44.0/.github/chart.svg 0000664 0000000 0000000 00000006241 14675720665 0016134 0 ustar 00root root 0000000 0000000
resvg-0.44.0/.github/pull_request_template.md 0000664 0000000 0000000 00000000413 14675720665 0021246 0 ustar 00root root 0000000 0000000 Pull requests that include:
- dependencies updates
- code formatting fixes
- clippy fixes
- compiler warnings fixes
will not be accepted.
The only exception are spellchecking and grammar fixes.
A pull request must contain a meaningful improvement to the project.
resvg-0.44.0/.github/workflows/ 0000775 0000000 0000000 00000000000 14675720665 0016344 5 ustar 00root root 0000000 0000000 resvg-0.44.0/.github/workflows/main.yml 0000664 0000000 0000000 00000003740 14675720665 0020017 0 ustar 00root root 0000000 0000000 name: Build
on: [push, pull_request]
env:
CARGO_TERM_COLOR: always
jobs:
build:
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v3
# We have to use the Release mode, otherwise it would take forever.
- name: Test
run: cargo test --all --release
- name: Build C API
working-directory: crates/c-api
run: cargo build
- name: Build C API without default features
working-directory: crates/c-api
run: cargo build --no-default-features
- name: Build resvg without default support
working-directory: crates/resvg
run: cargo check --no-default-features
- name: Build usvg without default support
working-directory: crates/usvg
run: cargo check --no-default-features
msrv:
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v3
- name: Install toolchain
uses: dtolnay/rust-toolchain@stable
with:
toolchain: 1.67.1
- name: Build
run: cargo build
# We have some Windows specific code that we should check on each commit.
windows:
runs-on: windows-latest
steps:
- name: Checkout
uses: actions/checkout@v3
# Toolchain is stable-x86_64-pc-windows-msvc by default. No need to change it.
- name: Build thumbnailer
working-directory: tools/explorer-thumbnailer
env:
RUSTFLAGS: -Ctarget-feature=+crt-static # make sure it's static
run: cargo build
- name: Install Qt
uses: jurplel/install-qt-action@v4
with:
version: '5.15.2'
# Unlike other binaries, viewsvg isn't built with crt-static
- name: Build C API
working-directory: crates/c-api
run: cargo build --release
- name: Prepare Developer Command Prompt for MSVC
uses: ilammy/msvc-dev-cmd@v1
- name: Build viewsvg
working-directory: tools/viewsvg
run: |
qmake
nmake
resvg-0.44.0/.github/workflows/tagged-release.yml 0000664 0000000 0000000 00000015355 14675720665 0021751 0 ustar 00root root 0000000 0000000 name: "Tagged Release"
on:
push:
tags:
- "*"
env:
CARGO_TERM_COLOR: always
jobs:
create-release:
name: Create Release
runs-on: ubuntu-20.04
steps:
- name: Create Release
id: create_release
uses: softprops/action-gh-release@v2
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
tag_name: ${{ github.ref }}
name: ${{ github.ref }}
body: |
- `viewsvg` is a simple application that showcases *resvg* capabilities
- `resvg-0.*.0.tar.xz` is a sources archive with vendored Rust dependencies
- `resvg-explorer-extension.exe` is an SVG thumbnailer for Windows Explorer
Check [CHANGELOG](https://github.com/RazrFalcon/resvg/blob/${{ github.ref }}/CHANGELOG.md).
draft: false
prerelease: false
outputs:
upload_url: ${{ steps.create_release.outputs.upload_url }}
release-linux:
name: Release Linux
runs-on: ubuntu-20.04
needs: ["create-release"]
steps:
- name: Checkout
uses: actions/checkout@v2
- name: Build resvg
run: cargo build --release
- name: Build usvg
working-directory: crates/usvg
run: cargo build --release
- name: Collect
working-directory: target/release
run: |
strip -s resvg
strip -s usvg
tar czf resvg-linux-x86_64.tar.gz resvg
tar czf usvg-linux-x86_64.tar.gz usvg
mkdir ../../bin
cp resvg-linux-x86_64.tar.gz ../../bin/
cp usvg-linux-x86_64.tar.gz ../../bin/
- name: Get version
id: get_version
uses: battila7/get-version-action@v2
- name: Make vendored archive
run: |
VERSION=${{ steps.get_version.outputs.version-without-v }}
echo $VERSION
git clone https://github.com/RazrFalcon/resvg resvg-$VERSION
cd resvg-"$VERSION"
mkdir -p .cargo
cargo vendor > .cargo/config
cd ..
env XZ_OPT="-9e" tar \
--exclude=".git" \
--exclude=".gitignore" \
--exclude="resvg-$VERSION/.github" \
--exclude="resvg-$VERSION/version-bump.md" \
--exclude="resvg-$VERSION/docs" \
-cJf resvg-"$VERSION".tar.xz resvg-"$VERSION"
cp resvg-"$VERSION".tar.xz bin/
- name: Upload binaries
uses: alexellis/upload-assets@0.2.2
env:
GITHUB_TOKEN: ${{ github.token }}
with:
asset_paths: '["bin/*"]'
release-windows:
name: Release Windows
runs-on: windows-2019
needs: ["create-release"]
steps:
- name: Checkout
uses: actions/checkout@v2
# Toolchain is stable-x86_64-pc-windows-msvc by default. No need to change it.
- name: Build resvg
env:
RUSTFLAGS: -Ctarget-feature=+crt-static # make sure it's static
run: cargo build --release
- name: Build usvg
working-directory: crates/usvg
env:
RUSTFLAGS: -Ctarget-feature=+crt-static # make sure it's static
run: cargo build --release
- name: Compress
working-directory: target/release
shell: cmd
run: |
7z a -tzip -mx9 resvg-win64.zip resvg.exe
7z a -tzip -mx9 usvg-win64.zip usvg.exe
- name: Build thumbnailer
working-directory: tools/explorer-thumbnailer
env:
RUSTFLAGS: -Ctarget-feature=+crt-static # make sure it's static
run: cargo build --release
- name: Build thumbnailer installer
working-directory: tools/explorer-thumbnailer/install
shell: cmd
run: |
"%programfiles(x86)%\Inno Setup 6\iscc.exe" "installer.iss"
- name: Install Qt
uses: jurplel/install-qt-action@v2
with:
version: '5.15.2'
# Unlike other binaries, viewsvg isn't built with crt-static
- name: Build C API
working-directory: crates/c-api
run: cargo build --release
- name: Prepare Developer Command Prompt for MSVC
uses: ilammy/msvc-dev-cmd@v1
- name: Build viewsvg
working-directory: tools/viewsvg
run: |
qmake
nmake
mkdir viewsvg-bin
cp release/viewsvg.exe viewsvg-bin/viewsvg.exe
windeployqt --no-translations viewsvg-bin/viewsvg.exe
del viewsvg-bin/libGLESv2.dll
del viewsvg-bin/libEGL.dll
del viewsvg-bin/d3dcompiler_47.dll
del viewsvg-bin/opengl32sw.dll
Remove-Item "viewsvg-bin/iconengines" -Recurse
Remove-Item "viewsvg-bin/imageformats" -Recurse
cd viewsvg-bin
7z a -tzip -mx9 viewsvg-win64.zip *
- name: Collect
run: |
mkdir bin
cp target/release/resvg-win64.zip bin/
cp target/release/usvg-win64.zip bin/
cp tools/explorer-thumbnailer/install/resvg-explorer-extension.exe bin/
cp tools/viewsvg/viewsvg-bin/viewsvg-win64.zip bin/
- name: Upload binaries
uses: alexellis/upload-assets@0.2.2
env:
GITHUB_TOKEN: ${{ github.token }}
with:
asset_paths: '["bin/*"]'
release-macos:
name: Release macOS
runs-on: macos-latest
needs: ["create-release"]
steps:
- name: Checkout
uses: actions/checkout@v2
# Some weird CI glitch. Make sure we have the latest Rust.
- name: Install latest stable toolchain
uses: dtolnay/rust-toolchain@stable
- name: Build resvg
run: cargo build --release
- name: Build usvg
working-directory: crates/usvg
run: cargo build --release
- name: Compress
working-directory: target/release
run: |
7z a -tzip -mx9 resvg-macos-x86_64.zip resvg
7z a -tzip -mx9 usvg-macos-x86_64.zip usvg
- name: Build C API
working-directory: crates/c-api
run: cargo build --release
- name: Install Qt
uses: jurplel/install-qt-action@v2
with:
version: '5.15.2'
- name: Build viewsvg
working-directory: tools/viewsvg
run: |
qmake
make
macdeployqt viewsvg.app
rm -r viewsvg.app/Contents/Plugins/iconengines
rm -r viewsvg.app/Contents/Plugins/imageformats
7z a -tzip -mx9 viewsvg-macos-x86_64.zip viewsvg.app
- name: Collect
run: |
mkdir bin
cp target/release/resvg-macos-x86_64.zip bin/
cp target/release/usvg-macos-x86_64.zip bin/
cp tools/viewsvg/viewsvg-macos-x86_64.zip bin/
- name: Upload binaries
uses: alexellis/upload-assets@0.2.2
env:
GITHUB_TOKEN: ${{ github.token }}
with:
asset_paths: '["bin/*"]'
resvg-0.44.0/.gitignore 0000664 0000000 0000000 00000000062 14675720665 0014735 0 ustar 00root root 0000000 0000000 target
.directory
.DS_Store
.vscode
tools/build-*
resvg-0.44.0/CHANGELOG.md 0000664 0000000 0000000 00000160340 14675720665 0014564 0 ustar 00root root 0000000 0000000 # Change Log
All notable changes to this project will be documented in this file.
The format is based on [Keep a Changelog](http://keepachangelog.com/)
and this project adheres to [Semantic Versioning](http://semver.org/).
This changelog also contains important changes in dependencies.
## [Unreleased]
## [0.44.0] - 2024-09-28
### Added
- Stylesheet injection support.
Thanks to [@LaurenzV](https://github.com/LaurenzV).
- (c-api) `resvg_get_object_bbox`
- (c-api) `cargo-c` metadata.
Thanks to [@lu-zero](https://github.com/lu-zero).
- Implement `From` for `fontdb` and `usvg` font types.
Thanks to [@dhardy](https://github.com/dhardy).
### Changed
- (c-api) `resvg_get_image_bbox` returns a _layer_ and not _object_ bounding box now.
Use `resvg_get_object_bbox` to preserve the old behavior.
### Fixed
- (svgtypes) Path parsing with `S` or `T` segments after `A`.
- Bounding box calculation for the root group used for `viewBox` flattening.
## [0.43.0] - 2024-08-10
### Added
- Support WebP images.
Thanks to [@notjosh](https://github.com/notjosh).
### Changed
- Use `zune-jpeg` instead of `jpeg-decoder`.
Thanks to [@mattfbacon](https://github.com/mattfbacon).
- Update dependencies.
### Fixed
- Canvas size limits calculation.
- SVG fonts handling.
Thanks to [@LaurenzV](https://github.com/LaurenzV).
- Transforms in COLR fonts.
Thanks to [@LaurenzV](https://github.com/LaurenzV).
## [0.42.0] - 2024-06-01
### Added
- `resvg` can render color fonts now, aka Emojis.
In TrueType terms, `COLRv0`, `COLRv1` (mostly), `sbix`, `CBDT` and `SVG` tables are supported.
Thanks to [@LaurenzV](https://github.com/LaurenzV).
- Fonts matching and fallback can be controlled by the caller via `usvg::FontResolver` now.
Thanks to [@LaurenzV](https://github.com/LaurenzV).
- `usvg::Options::font_resolver`. Similar to `usvg::Options::image_href_resolver` we already had.
- `usvg::Options::fontdb`
- Support double-quoted FuncIRIs, aka `url("#id")`.
- `image` element viewbox flattening.
Instead of having `usvg::Image::view_box` that the caller should handle themselves,
we instead replace it with `transform` and optional `clip-path`.
This greatly simplifies `image` rendering.
- `usvg::Image::size`
- Tree viewbox flattening.
Similar to `image` above, but affects the root `svg` element instead.
- `pattern` viewbox flattening.
Similar to `image` above, but for patterns.
- Improve vertical text rendering.
Thanks to [@LaurenzV](https://github.com/LaurenzV).
### Changed
- `usvg::fontdb::Database` should be set in `usvg::Options` and not passed
to the parser separately now.
- `usvg::Options` and `usvg::ImageHrefResolver` have a lifetime now.
- Replace `usvg::Visibility` enum with just `bool`.
- `usvg::Path::visibility()` is replaced with `usvg::Path::is_visible()`
- `usvg::Image::visibility()` is replaced with `usvg::Image::is_visible()`
- `usvg::TextSpan::visibility()` is replaced with `usvg::TextSpan::is_visible()`
- Always represent `feImage` content as a link to an element.
In SVG, `feImage` can contain a link to an element or a base64 image data, just like `image`.
From now, the inlined base64 data will always be represented by a link to an actual `image` element.
```xml
```
will be parsed as
```xml
```
This simplifies `feImage` rendering, since we don't have to handle both cases now.
- The `--list-fonts` resvg argument can be used without providing an SVG file now.
Can simply call `resvg --list-fonts` now.
- The `--list-fonts` resvg argument includes generic font family names as well now.
- Make sure all warning and errors are printed to stderr.
Thanks to [@ahaoboy](https://github.com/ahaoboy).
### Removed
- `usvg::ViewBox`, `usvg::AspectRatio`, `usvg::Align` types. Nol longer used.
- `usvg::filter::Image::aspect`. No longer needed.
- `usvg::filter::Image::rendering_mode`. No longer needed.
- `usvg::filter::Image::data`. Use `usvg::filter::Image::root` instead.
- `usvg::Tree::view_box`. No longer needed.
- `usvg::Image::view_box`. No longer needed.
- `usvg::Image::pattern`. No longer needed.
- `usvg::utils::align_pos`. No longer needed.
- `usvg::Visibility`. No longer needed.
- (c-api) `resvg_get_image_viewbox`. Use `resvg_get_image_size` instead.
### Fixed
- `context-fill` handling.
Thanks to [@LaurenzV](https://github.com/LaurenzV).
## [0.41.0] - 2024-04-03
### Added
- `context-fill` and `context-stroke` support.
Thanks to [@LaurenzV](https://github.com/LaurenzV).
- `usvg::Text::layouted()`, which returns a list of glyph IDs.
It can be used to manually draw glyphs, unlike with `usvg::Text::flattened()`, which returns
just vector paths.
Thanks to [@LaurenzV](https://github.com/LaurenzV).
### Fixed
- Missing text when a `text` element uses multiple fonts and one of them produces ligatures.
- Absolute transform propagation during `use` resolving.
- Absolute transform propagation during nested `svg` resolving.
- `Node::abs_transform` documentation. The current element's transform _is_ included.
## [0.40.0] - 2024-02-17
### Added
- `usvg::Tree` is `Send + Sync` compatible now.
- `usvg::WriteOptions::preserve_text` to control how `usvg` generates an SVG.
- `usvg::Image::abs_bounding_box`
### Changed
- All types in `usvg` are immutable now. Meaning that `usvg::Tree` cannot be modified
after creation anymore.
- All struct fields in `usvg` are private now. Use getters instead.
- All `usvg::Tree` parsing methods require the `fontdb` argument now.
- All `defs` children like gradients, patterns, clipPaths, masks and filters are guarantee
to have a unique, non-empty ID.
- All `defs` children like gradients, patterns, clipPaths, masks and filters are guarantee
to have `userSpaceOnUse` units now. No `objectBoundingBox` units anymore.
- `usvg::Mask` is allowed to have no children now.
- Text nodes will not be parsed when the `text` build feature isn't enabled.
- `usvg::Tree::clip_paths`, `usvg::Tree::masks`, `usvg::Tree::filters` returns
a pre-collected slice of unique nodes now.
It's no longer a closure and you do not have to deduplicate nodes by yourself.
- `usvg::filter::Primitive::x`, `y`, `width` and `height` methods were replaced
with `usvg::filter::Primitive::rect`.
- Split `usvg::Tree::paint_servers` into `usvg::Tree::linear_gradients`,
`usvg::Tree::radial_gradients`, `usvg::Tree::patterns`.
All three returns pre-collected slices now.
- A `usvg::Path` no longer can have an invalid bbox. Paths with an invalid bbox will be
rejected during parsing.
- All `usvg` methods that return bounding boxes return non-optional `Rect` now.
No `NonZeroRect` as well.
- `usvg::Text::flattened` returns `&Group` and not `Option<&Group>` now.
- `usvg::ImageHrefDataResolverFn` and `usvg::ImageHrefStringResolverFn`
require `fontdb::Database` argument.
- All shared nodes are stored in `Arc` and not `Rc` now.
- `resvg::render_node` now includes filters bounding box. Meaning that a node with a blur filter
no longer be clipped.
- Replace `usvg::utils::view_box_to_transform` with `usvg::ViewBox::to_transform`.
- Rename `usvg::XmlOptions` into `usvg::WriteOptions` and embed `xmlwriter::Options`.
### Removed
- `usvg::Tree::postprocess()` and `usvg::PostProcessingSteps`. No longer needed.
- `usvg::ClipPath::units()`, `usvg::Mask::units()`, `usvg::Mask::content_units()`,
`usvg::Filter::units()`, `usvg::Filter::content_units()`, `usvg::LinearGradient::units()`,
`usvg::RadialGradient::units()`, `usvg::Pattern::units()`, `usvg::Pattern::content_units()`
and `usvg::Paint::units()`. They are always `userSpaceOnUse` now.
- `usvg::Units`. No longer needed.
### Fixed
- Text bounding box is accounted during SVG size resolving.
Previously, only paths and images were included.
- Font selection when an italic font isn't explicitly marked as one.
- Preserve `image` aspect ratio when only `width` or `height` are present.
Thanks to [@LaurenzV](https://github.com/LaurenzV).
## [0.39.0] - 2024-02-06
### Added
- `font` shorthand parsing.
Thanks to [@LaurenzV](https://github.com/LaurenzV).
- `usvg::Group::abs_bounding_box`
- `usvg::Group::abs_stroke_bounding_box`
- `usvg::Path::abs_bounding_box`
- `usvg::Path::abs_stroke_bounding_box`
- `usvg::Text::abs_bounding_box`
- `usvg::Text::abs_stroke_bounding_box`
### Changed
- All `usvg-*` crates merged into one. There is just the `usvg` crate now, as before.
### Removed
- `usvg::Group::abs_bounding_box()` method. It's a field now.
- `usvg::Group::abs_filters_bounding_box()`
- `usvg::TreeParsing`, `usvg::TreePostProc` and `usvg::TreeWriting` traits.
They are no longer needed.
### Fixed
- `font-family` parsing.
Thanks to [@LaurenzV](https://github.com/LaurenzV).
- Absolute bounding box calculation for paths.
## [0.38.0] - 2024-01-21
### 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` access.
- Tree nodes respect tree's mutability rules. Before, one could mutate tree nodes when the tree
itself is not mutable. Because `Rc` provides a shared mutable access.
- Filters, clip paths, masks and patterns are stored as `Rc>` instead of `Rc`.
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](https://github.com/LaurenzV).
## [0.37.0] - 2023-12-16
### Added
- `usvg` can write text back to SVG now.
Thanks to [@LaurenzV](https://github.com/LaurenzV).
- `--preserve-text` flag to the `usvg` CLI tool.
Thanks to [@LaurenzV](https://github.com/LaurenzV).
- Support [`transform-origin`](https://drafts.csswg.org/css-transforms/#transform-origin-property)
property.
Thanks to [@LaurenzV](https://github.com/LaurenzV).
- Support non-default markers order via
[`paint-order`](https://svgwg.org/svg2-draft/painting.html#PaintOrder).
Previously, only fill and stroke could have been swapped.
Thanks to [@LaurenzV](https://github.com/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`.
`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 `clipPath`s
and `filter`s 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.
It doesn't break anything, because those properties were never used before anyway.
Thanks to [@LaurenzV](https://github.com/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](https://github.com/LaurenzV).
- Indirect `text-decoration` resolving in some cases.
Thanks to [@LaurenzV](https://github.com/LaurenzV).
- (usvg) Clip paths writing to SVG.
Thanks to [@LaurenzV](https://github.com/LaurenzV).
## [0.36.0] - 2023-10-01
### Added
- `stroke-linejoin=miter-clip` support. SVG2.
Thanks to [@torokati44](https://github.com/torokati44).
- Quoted FuncIRI support. Like `fill="url('#gradient')"`. SVG2.
Thanks to [@romanzes](https://github.com/romanzes).
- Allow float values in `rgb()` and `rgba()` colors. SVG2.
Thanks to [@yisibl](https://github.com/yisibl).
- `auto-start-reverse` variant support to `orient` in markers. SVG2.
Thanks to [@EpicEricEE](https://github.com/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](https://github.com/wez).
- (Qt API) Fix scaling factor calculation.
Thanks to [@missdeer](https://github.com/missdeer).
## [0.35.0] - 2023-06-27
### 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`.
## [0.34.1] - 2023-05-28
### Fixed
- Transform components order. Affects only `usvg` SVG output and C API.
## [0.34.0] - 2023-05-27
### Changed
- `usvg` uses `tiny-skia` geometry primitives now, including the `Path` container.
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`.
`tiny-skia` primitives are move robust, strict and have a nicer API.
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.
## [0.33.0] - 2023-05-17
### Added
- A new rendering algorithm.
When rendering [isolated groups](https://razrfalcon.github.io/notes-on-svg-parsing/isolated-groups.html),
aka layers, we have to know the layer bounding box beforehand, which is ridiculously hard in SVG.
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.
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.
Moreover, it makes performance more linear with a canvas size increase.
The [paris-30k.svg](https://github.com/google/forma/blob/681e8bfd348caa61aab47437e7d857764c2ce522/assets/svgs/paris-30k.svg)
sample from [google/forma](https://github.com/google/forma) is rendered _115 times_ faster on M1 Pro now.
From ~33760ms down to ~290ms. 5269x3593px canvas.
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`.
## [0.32.0] - 2023-04-23
### 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.
## [0.31.1] - 2023-04-22
### Fixed
- Use the latest `tiny-skia` to fix SVGs with large masks rendering.
## [0.31.0] - 2023-04-10
### 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](https://github.com/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.
## [0.30.0] - 2023-03-25
### 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](https://github.com/LaurenzV).
- Panic when applying `text-decoration` on text with only one cluster.
Thanks to [@LaurenzV](https://github.com/LaurenzV).
- (Qt API) Image size wasn't initialized. Thanks to [@missdeer](https://github.com/missdeer).
- `resvg` CLI allows files with XML DTD again.
- (svgtypes) Handle implicit MoveTo after ClosePath segments.
## [0.29.0] - 2023-02-04
### Added
- `resvg` CLI loads system fonts only when an input SVG has text nodes now.
Fonts loading is an IO-heavy operation and by avoiding it we can speed up `resvg` execution.
- `usvg::Group::should_isolate`
- `usvg::Tree::has_text_nodes`
### Changed
- Some `usvg` internals were moved into the new `rosvgtree` crate.
- Dummy groups are no longer removed. Use `usvg::Group::should_isolate` to check
if a group affects rendering.
- `usvg-text-layout::TreeTextToPath::convert_text` no longer has the `keep_named_groups` argument.
- MSRV bumped to 1.65
- Update dependencies.
### Removed
- `usvg::Options::keep_named_groups`. Dummy groups are no longer removed.
- (c-api) `resvg_options_set_keep_named_groups`
- (Qt API) `ResvgOptions::setKeepNamedGroups`
### Fixed
- Missing `font-family` handling.
- `font-weight` resolving.
## [0.28.0] - 2022-12-03
### Added
- `usvg::Text` and `usvg::NodeKind::Text`.
### Changed
- `usvg` isn't converting text to paths by default now. A caller must call
`usvg::Tree::convert_text` or `usvg::Text::convert` from `usvg-text-layout` crate on demand.
- `usvg` text layout implementation moved into `usvg-text-layout` crate.
- During SVG size recovery, when no `width`, `height` and `viewBox` attributes have been set,
text nodes are no longer taken into an account. This is because a text node has no bbox
before conversion into path(s), which we no longer doing during parsing.
- `usvg` is purely an SVG parser now. It doesn't convert text to paths
and doesn't write SVG anymore.
- `usvg::filter::ConvolveMatrixData` methods are fields now.
### Removed
- `usvg` CLI binary. No alternatives for now.
- All `usvg` build features.
- `filter`. Filter elements are always parsed by `usvg` now.
- `text`. Text elements are always parsed by `usvg` now.
- `export`. `usvg` cannot write an SVG anymore.
- `usvg::Tree::to_string`. `usvg` cannot write an SVG anymore.
- `usvg::TransformFromBBox` trait. This is just a regular `usvg::Transform` method now.
- `usvg::OptionsRef`. `usvg::Options` is enough from now.
- `usvg::Options::fontdb`. Used only by `usvg-text-layout` now.
- `--dump-svg` from `resvg`.
## [0.27.0] - 2022-11-27
### Added
- `lengthAdjust` and `textLength` attributes support.
- Support automatic `image` size detection.
`width` and `height` attributes can be omitted or set to `auto` on `image` now. SVG2
### Fixed
- `--query-all` flag in `resvg` CLI.
- Percentage values resolving.
## [0.26.1] - 2022-11-21
### Fixed
- Allow `dominant-baseline` and `alignment-baseline` to be set via CSS.
## [0.26.0] - 2022-11-20
### Added
- Minimal `dominant-baseline` and `alignment-baseline` support.
- `mix-blend-mode` and `isolation` support. SVG2
- Allow writing resvg output to stdout.
- Allow disabling text kerning using `kerning="0"` and `style="font-kerning:none"`. SVG2
- Allow `` values for `opacity`, `fill-opacity`, `stroke-opacity`,
`flood-opacity` and `stop-opacity` attributes.
You can write `opacity="50%"` now. SVG2
### Changed
- Disable focal point correction on radial gradients to conform with SVG 2. SVG2
- Update `feMorphology` radius value resolving.
### Fixed
- Do not clip nested `svg` when only the `viewBox` attribute is present.
## [0.25.0] - 2022-10-30
### Added
- Partial `paint-order` attribute support.
Markers can only be under or above the shape.
### Fixed
- Compilation issues caused by `rustybuzz` update.
## [0.24.0] - 2022-10-22
### Added
- CSS3 `writing-mode` variants `vertical-rl` and `vertical-lr`.
Thanks to [yisibl](https://github.com/yisibl).
- (tiny-skia) AArch64 Neon SIMD support. Up to 3x faster on Apple M1.
### Changed
- `usvg::Tree` stores only `Group`, `Path` and `Image` nodes now.
Instead of emulating an SVG file structure, where gradients, patterns, filters, clips and masks
are part of the nodes tree (usually inside the `defs` element), we reference them using `Rc`
from now.
This change makes `usvg` a bit simpler. Makes `usvg` API way easier, since instead of
looking for a node via `usvg::Tree::defs_by_id` the caller can access the type directly via `Rc`.
And makes creation of custom `usvg::Tree`s way easier.
- `clip_path`, `mask` and `filters` `usvg::Group` fields store `Rc` instead of `String` now.
- `usvg::NodeExt::units` was moved to `usvg::Paint::units`.
- `usvg::filter::ImageKind::Use` stores `usvg::Node` instead of `String`.
- `usvg::PathData` stores commands and points separately now to reduce overall memory usage.
- `usvg::PathData` segments should be accessed via `segments()` now.
- Most numeric types have been moved to the `strict-num` crate.
- Rename `NormalizedValue` into `NormalizedF64`.
- Rename `PositiveNumber` into `PositiveF64`.
- Raw number of numeric types should be accessed via `get()` method instead of `value()` now.
- `usvg::TextSpan::font_size` is `NonZeroPositiveF64` instead of `f64` now.
- Re-export `usvg` and `tiny-skia` dependencies in `resvg`.
- Re-export `roxmltree` dependency in `usvg`.
- (usvg) Output float precision is reduced from 11 to 8 digits.
### Removed
- `usvg::Tree::create`. `usvg::Tree` is an open struct now.
- `usvg::Tree::root`. It's a public field now.
- `usvg::Tree::svg_node`. Replaced with `usvg::Tree` public fields.
- `defs`, `is_in_defs`, `append_to_defs` and `defs_by_id` from `usvg::Tree`.
We no longer emulate SVG structure. No alternative.
- `usvg::Tree::is_in_defs`. There are no `defs` anymore.
- `usvg::Paint::Link`. We store gradient and patterns directly in `usvg::Paint` now.
- `usvg::Svg`. No longer needed. `size` and `view_box` are `usvg::Tree` fields now.
- `usvg::SubPathIter` and `usvg::PathData::subpaths`. No longer used.
### Fixed
- Path bbox calculation scales stroke width too.
Thanks to [growler](https://github.com/growler).
- (tiny-skia) Round caps roundness.
- (xmlparser) Stack overflow on specific files.
- (c-api) `resvg_is_image_empty` output was inverted.
## [0.23.0] - 2022-06-11
### Added
- `#RRGGBBAA` and `#RGBA` color notation support.
Thanks to [demurgos](https://github.com/demurgos).
### Fixed
- Panic during recursive `pattern` resolving.
Thanks to [FylmTM](https://github.com/FylmTM).
- Spurious warning when using `--export-id`.
Thanks to [benoit-pierre](https://github.com/benoit-pierre).
## [0.22.0] - 2022-02-20
### Added
- Support `svg` referenced by `use`. External SVG files are still not supported.
### Changed
- `ttf-parser`, `fontdb` and `rustybuzz` have been updated.
## [0.21.0] - 2022-02-13
### Added
- `usvg::ImageHrefResolver` that allows a custom `xlink:href` handling.
Thanks to [antmelnyk](https://github.com/antmelnyk).
- `usvg::Options::image_href_resolver`
- Support for GIF images inside the `` element.
- (fontdb) Support for loading user fonts on Windows.
- (fontdb) Support for parsing fontconfig config files on Linux.
For now, only to retrieve a list of font dirs.
### Changed
- MSRV bumped to 1.51
- `usvg::ImageKind` stores data as `Arc>` and not just `Vec` now.
### Fixed
- Every nested `svg` element defines a new viewBox now. Previously, we were always using the root one.
- Correctly handle SVG size calculation when SVG doesn't have a size and any elements.
- Improve groups ungrouping speed.
## [0.20.0] - 2021-12-29
### Changed
- `resvg::render` and `resvg::render_node` accept a transform now.
- (c-api) `resvg_render` and `resvg_render_node` accept a transform now.
- `usvg::Color` is a custom type and not a `svgtypes::Color` reexport now.
- `usvg::Color` doesn't contain alpha anymore, which have been added in v0.16
Alpha would be automatically flattened.
This makes [Micro SVG](https://github.com/RazrFalcon/resvg/blob/master/docs/usvg_spec.adoc)
compatible with SVG 1.1 again.
- (c-api) Rename `RESVG_FIT_TO_*` into `RESVG_FIT_TO_TYPE_*`.
### Fixed
- The `--background` argument in `resvg` correctly handles alpha now.
- Fix building usvg without filter feature but with export.
## [0.19.0] - 2021-10-04
### Added
- Better text-on-path converter accuracy by accounting the current transform.
### Changed
- `usvg::NodeExt::abs_transform` includes current node transform now.
- Improved turbulence filter performance. Thanks to [akindle](https://github.com/akindle).
- Multiple dependencies updated.
## [0.18.0] - 2021-09-12
### Added
- `filter` build feature. Enabled by default.
- `usvg::PathBbox` and `resvg_path_bbox` (to C API).
### Changed
- (usvg) All filter related types are under the `filter` module now.
- (usvg) Remove `Fe` prefix from all filter types.
- (c-api) `resvg_get_node_bbox` returns `resvg_path_bbox` now.
### Fixed
- Horizontal and vertical lines processing.
- C API building without the `text` feature.
## [0.17.0] - 2021-09-04
### Added
- `tiny-skia` updated with support of images larger than 8000x8000 pixels.
- `feDropShadow` support. SVG2
- [``](https://www.w3.org/TR/filter-effects-1/#typedef-filter-value-list) support.
Meaning that the `filter` attribute can have multiple values now.
Like `url(#filter1) blur(2)`. SVG2
- All [filter functions](https://www.w3.org/TR/filter-effects-1/#filter-functions). SVG2
- Support all [new](https://www.w3.org/TR/compositing-1/#ltblendmodegt) `feBlend` modes. SVG2
- Automatic SVG size detection when `width`/`height`/`viewBox` is not set.
Thanks to [reknih](https://github.com/reknih).
- `usvg::Options::default_size`
- `--default-width` and `--default-height` to usvg.
### Changed
- `usvg::Group::filter` is a list of filter IDs now.
- `usvg::FeColorMatrixKind::Saturate` accepts any positive `f64` value now.
- `svgfilters::ColorMatrix::Saturate` accepts any positive `f64` value now.
- Fonts memory mapping was split into a separate build feature: `memmap-fonts`.
Now you can build resvg/usvg with `system-fonts`, but without `memmap-fonts`.
Enabled by default.
- The `--dump-svg` argument in resvg CLI tool should be enabled using `--features dump-svg` now.
No enabled by default.
- `usvg::Tree::to_string` is behind the `export` build feature now.
### Fixed
- When writing SVG, `usvg` will use `rgba()` notations for colors instead of `#RRGGBB`.
## [0.16.0] - 2021-08-22
### Added
- CSS3 colors support. Specifically `rgba`, `hsl`, `hsla` and `transparent`. SVG2
- Allow missing `rx`/`ry` attributes on `ellipse`. SVG2
- Allow markers on all shapes. SVG2
- `textPath` can reference basic shapes now. SVG2
- `usvg::OptionsRef`, which is a non-owned `usvg::Options` variant.
- `simplecss` updated with CSS specificity support.
- `turn` angle unit support. SVG2
- Basic `font-variant=small-caps` support. No font fallback.
- `--export-area-page` to resvg.
- `--export-area-drawing` to resvg.
### Changed
- `resvg::render_node` requires `usvg::Tree` now.
- `usvg::Color` gained an `alpha` field.
### Removed
- `usvg::Node::tree`. Cannot be implemented efficiently anymore.
- `usvg::SystemFontDB`. No longer needed.
### Fixed
- `pattern` scaling.
- Greatly improve `symbol` resolving speed in `usvg`.
- Whitespaces trimming on nested `tspan`.
## [0.15.0] - 2021-06-13
### Added
- Allow reading SVG from stdin in `resvg` binary.
- `--id-prefix` to `usvg`.
- `FitTo::Size`
- `resvg` binary accepts `--width` and `--height` args together now.
Previously, only `--width` or `--height` were allowed.
- `usvg::Path::text_bbox`
- The maximum number of SVG elements is limited by 1_000_000 now.
Mainly to prevent a billion laugh style attacks.
- The maximum SVG elements nesting is limited by 1024 now.
- `usvg::Error::ElementsLimitReached`
### Changed
- Improve clipping and masking performance on large images.
- Remove layers caching. This was a pointless optimization.
- Split _Preprocessing_ into _Reading_ and _Parsing_ in `resvg --perf`.
- `usvg::XmlOptions` rewritten.
- `usvg::Tree::to_string` requires a reference to `XmlOptions` now.
### Removed
- `usvg::Tree::from_file`. Use `from_data` or `from_str` instead.
- `usvg::Error::InvalidFileSuffix`
- `usvg::Error::FileOpenFailed`
- (c-api) `RESVG_ERROR_INVALID_FILE_SUFFIX`
### Fixed
- Ignore tiny blur values. It could lead to a transparent image.
- `use` style propagation when used with `symbol`.
- Vertical text layout with relative offsets.
- Text bbox calculation. `usvg` uses font metrics instead of path bbox now.
## [0.14.1] - 2021-04-18
### Added
- Allow `href` without the `xlink` namespace.
This feature is part of SVG 2 (which we do not support),
but there are more and more files like this in the wild.
### Changed
- (usvg) Do not write `usvg:version` to the output SVG.
### Fixed
- (usvg) `overflow='inherit'` resolving.
- (usvg) SVG Path length calculation that affects `startOffset` property in `textPath`.
- (usvg) Fix `feImage` resolving when the linked element has
`opacity`, `clip-path`, `mask` and/or `filter` attributes.
- (usvg) Fix chained `feImage` resolving.
- CLI arguments processing.
## [0.14.0] - 2021-03-06
### Fixed
- Multiple critical bugs in `tiny-skia`.
## [0.13.1] - 2021-01-20
### Fixed
- `image` with float size scaling.
- Critical bug in `tiny-skia`.
## [0.13.0] - 2020-12-21
### Added
- `--resources-dir` option to CLI tools.
- (usvg) `Tree::from_xmltree`
### Changed
- Remove the `Image` struct. `render()` and `render_node()` methods now accept `tiny_skia::PixmapMut`.
- Update `fontdb`.
- Update `tiny-skia`.
- (c-api) `resvg_size` uses `double` instead of `uint32_t` now.
- (qt-api) `defaultSize()` and `defaultSizeF()` methods now return SVG size
and not SVG viewbox size.
- (usvg) `Options::path` changed to `Options::resources_dir` and requires a directory now.
- (c-api) `resvg_options_set_file_path` changed to `resvg_options_set_resources_dir`
and requires a directory now.
- (qt-api) `ResvgOptions::setFilePath` changed to `ResvgOptions::setResourcesDir`
and requires a directory now.
### Fixed
- Support multiple values inside a `text-decoration` attribute.
### Removed
- `Image`. Use `tiny_skia::PixmapMut` instead.
- (c-api) `resvg_image` struct and `resvg_image_*` methods. `resvg` renders onto
the provided buffer now.
- (c-api) `resvg_color`, because unused.
## [0.12.0] - 2020-12-05
### Changed
- resvg no longer requires a C++ compiler!
- `tiny-skia` was updated to a pure Rust version, which means that `resvg` no longer
depends on `clang` and should work on 32bit targets.
- `rustybuzz` was updated to a pure Rust version.
- `tools/explorer-thumbnailer` is back and written in Rust now.
Thanks to [gentoo90](https://github.com/gentoo90).
### Fixed
- (usvg) Do not panic when a font has a zero-sized underline thickness.
- (usvg) Multiple `textPath` processing fixes by [chubei-oppen](https://github.com/chubei-oppen).
- (qt-api) `boundsOnElement` and `boundingBox` were returning transposed bounds.
## [0.11.0] - 2020-07-04
### Highlights
- All backends except Skia were removed. Skia is the only official one from now.
- New C API implementation.
### Added
- Support for user-defined fonts in usvg, resvg and C API.
- `--serif-family`, `--sans-serif-family`, `--cursive-family`, `--fantasy-family`
`--monospace-family`, `--use-font-file`, `--use-fonts-dir`, `--skip-system-fonts` and `--list-fonts`
options to all CLI tools.
- New tests suite. Instead of testing against the previous build, now we're testing against
prerendered PNG images. Which is way faster.
And you can test resvg without the internet connection now.
And all you need is just `cargo test`.
### Changed
- Library uses an embedded Skia by default now.
- Switch `harfbuzz_rs` with `rustybuzz`.
- Rendering doesn't require `usvg::Options` now.
- (usvg) The `fontdb` module moved into its own crate.
- (usvg) `fontconfig` is no longer used for matching
[generic fonts](https://www.w3.org/TR/2018/REC-css-fonts-3-20180920/#generic-family-value)
on Linux. Mainly because it's very slow.
- (usvg) When an `image` element contains a file path, the file will be loaded into memory now,
instead of simply storing a file path. And will be dumped as base64 on SVG save.
In case of an SVG image, it will be loaded as a `Tree` and saved as base64 encoded XML on save.
- (usvg) `ImageData` replaced with `ImageKind`.
- (usvg) Fonts database is empty by default now and should be filled manually.
- (c-api) Almost a complete rewrite.
### Removed
- All backends except the Skia one.
- `Options` from all backends. We don't use it anymore.
- (usvg) `ImageFormat`.
- (c-api) Rendering on a backends canvas no longer supported. Was constantly misused.
## [0.10.0] - 2020-06-19
### Changed
- The `resvg` crate has been split into four: resvg-cairo, resvg-qt, resvg-skia and resvg-raqote.
So from now, instead of enabling a required backend via cargo features,
you should select a required backend-specific crate.
This allows us to have a better integration with a selected 2D library.
And we also have separated C API implementations now.
And each backend has its own vendored archive too.
- (qt-backend) Use `QImage` instead of Rust libraries for raster images loading.
### Removed
- The `resvg` crate. Use backend-specific crates.
- `tools/rendersvg`. Each backend has its own CLI tool now.
- `tools/usvg`. `usvg` implements CLI by default now.
- (c-api) `resvg_*_render_to_file` methods.
- (qt-backend) `jpeg-decoder` and `png` dependencies.
## [0.9.1] - 2020-06-03
### Fixed
- Stack overflow when `enable-background` and `filter` are set on the same element.
- Grayscale PNG loading.
- Allow building on BSD.
- (usvg) Font fallback when shaping produces a different amount of glyphs.
- (usvg) Ignore a space after the last character during `letter-spacing` processing.
- (usvg) `marker-end` rendering when the last segment is a curve with the second control point
that coincides with end point.
- (usvg) Accept embedded `image` data without mime.
- (usvg) Fonts search in a home directory on Linux.
- (usvg) `dy` calculation for `textPath` thanks to [Stoeoef](https://github.com/Stoeoef)
- (usvg) `textPath` resolving when a referenced path has a transform.
Thanks to [Stoeoef](https://github.com/Stoeoef).
- (usvg) Load user fonts on macOS too.
- (xmlparser) Parsing comment before DTD.
## [0.9.0] - 2020-01-18
### Added
- `feConvolveMatrix`, `feMorphology`, `feDisplacementMap`, `feTurbulence`,
`feDiffuseLighting` and `feSpecularLighting` support.
- `BackgroundImage`, `BackgroundAlpha`, `FillPaint` and `StrokePaint` support as a filter input.
- Load grayscale raster images.
- `enable-background` support.
- resvg/usvg can be built without text rendering support now.
- `OutputImage::make_vec` and `OutputImage::make_rgba_vec`.
- `feImage` with a reference to an internal element.
### Changed
- `feComposite` k1-4 coefficients can have any number now.
This matches browsers behaviour.
- Use `flate2` instead of `libflate` for GZip decoding.
- (usvg) `fill` and `stroke` attributes will always be set for `path` now.
- (usvg) `g`, `path` and `image` can now be set inside `defs`. Required by `feImage`.
- (c-api) Rename `resvg_*_render_to_image` into `resvg_*_render_to_file`.
### Fixed
- (usvg) Transform processing during text-to-path conversion.
- `feComposite` with fully transparent region was producing an invalid result.
- Fallback to `matrix` in `feColorMatrix` when `type` is not set or invalid.
- ID preserving for `use` elements.
- `feFlood` with subregion and `primitiveUnits=objectBoundingBox`.
- (harfbuzz_rs) Memory leak.
## [0.8.0] - 2019-08-17
### Added
- A [Skia](https://skia.org/) backend thanks to
[JaFenix](https://github.com/JaFenix).
- `feComponentTransfer` support.
- `feColorMatrix` support.
- A better CSS support.
- An `*.otf` fonts support.
- (usvg) `dx`, `dy` are supported inside `textPath` now.
- Use a box blur for `feGaussianBlur` with `stdDeviation`>=2.
This is 4-8 times faster than IIR blur.
Thanks to [Shnatsel](https://github.com/Shnatsel).
### Changed
- All backends are using Rust crates for raster images loading now.
- Use `pico-args` instead of `gumdrop` to reduced the build time of `tools/rendersvg`
and `tools/usvg`.
- (usvg) The `xmlwriter` is used for SVG generation now.
Almost 2x faster than generating an `svgdom`.
- (usvg) Optimize font database initialization. Almost 50% faster.
- Use a lower PNG compression ratio to speed up PNG generation.
Depending on a backend and image can be 2-4x faster.
- `OutputImage::save` -> `OutputImage::save_png`.
- (usvg) `Path::segments` -> `Path::data`.
- Cairo backend compilation is 2x faster now due to overall changes.
- Performance improvements (Oxygen Icon theme SVG-to-PNG):
- cairo-backend: 22% faster
- qt-backend: 20% faster
- raqote-backend: 34% faster
### Fixed
- (qt-api) A default font resolving.
- (usvg) `baseline-shift` processing inside `textPath`.
- (usvg) Remove all `tref` element children.
- (usvg) `tref` with `xml:space` resolving.
- (usvg) Ignore nested `tref`.
- (usvg) Ignore invalid `clipPath` children that were referenced via `use`.
- (usvg) `currentColor` will always fallback to black now.
Previously, `stroke` was set to `none` which is incorrect.
- (usvg) `use` can reference an element inside a non-SVG element now.
- (usvg) Collect all styles for generic fonts and not only *Regular*.
- (usvg) Parse only presentation attributes from the `style` element and attribute.
### Removed
- (cairo-backend) `gdk-pixbuf` dependency.
- (qt-backend) JPEG image format plugin dependency.
- `svgdom` dependency.
## [0.7.0] - 2019-06-19
### Added
- New text layout implementation:
- `textPath` support.
- `writing-mode` support, aka vertical text.
- [Text BIDI reordering](http://www.unicode.org/reports/tr9/).
- Better text shaping.
- `word-spacing` is supported for all backends now.
- [`harfbuzz`](https://github.com/harfbuzz/harfbuzz) dependency.
- Subscript, superscript offsets are extracted from font and not hardcoded now.
- `shape-rendering`, `text-rendering` and `image-rendering` support.
- The `arithmetic` operator for `feComposite`.
- (usvg) `--quiet` argument.
- (c-api) `resvg_get_image_bbox`.
- (qt-api) `ResvgRenderer::boundingBox`.
- (resvg) A [raqote](https://github.com/jrmuizel/raqote) backend thanks to
[jrmuizel](https://github.com/jrmuizel). Still experimental.
### Changed
- Text will be converted into paths on the `usvg` side now.
- (resvg) Do not rescale images before rendering. This is faster and better.
- (usvg) An `image` element with a zero or negative size will be skipped now.
Previously, a linked image size was used, which is incorrect.
- Geometry primitives (`Rect`, `Size`, etc) are immutable and always valid now.
- (usvg) The default `color-interpolation-filters` attribute will not be exported now.
### Removed
- (usvg) All text related structures and enums. Text will be converted into `Path` now.
- `InitObject` and `init()` because they are no longer needed.
- (c-api) `resvg_handle`, `resvg_init`, `resvg_destroy`.
- (c-api) `resvg_cairo_get_node_bbox` and `resvg_qt_get_node_bbox`.
Use backend-independent `resvg_get_node_bbox` instead.
- (cairo-backend) `pango` dependency.
- (resvg) `Backend::calc_node_bbox`. Use `Node::calculate_bbox()` instead.
### Fixed
- `letter-spacing` on cursive scripts (like Arabic).
- (rctree) Prevent stack overflow on a huge, deeply nested SVG.
- (c-api) `resvg_is_image_empty` was always returning `false`.
- (resvg) Panic when `filter` with `objectBoudningBox` was set on an empty group.
- (usvg) `mask` with `objectBoundingBox` resolving.
- (usvg) `pattern`'s `viewBox` attribute resolving via `href`.
- (roxmltree) Namespace resolving.
## [0.6.1] - 2019-03-16
### Fixed
- (usvg) `transform` multiplication.
- (usvg) `use` inside `clipPath` resolving.
## [0.6.0] - 2019-03-16
### Added
- Nested `baseline-shift` support.
- (qt-api) `renderToImage`.
- (usvg) A better algorithm for unused defs (`defs` element children, like gradients) removal.
- (usvg) `Error::InvalidSize`.
- (c-api) `RESVG_ERROR_INVALID_SIZE`.
### Changed
- (usvg) A major rewrite.
- `baseline-shift` with `sub`, `super` and percent values calculation.
- Marker resolving moved completely to `usvg`.
- If an SVG doesn't have a valid size than an error will occur.
Previously, an empty tree was produced.
- (qt-api) `render` methods are `const` now.
- (usvg) Disable default attributes exporting.
### Removed
- (usvg) Marker element and attributes. Markers will be resolved just like `use` now.
### Fixed
- (resvg) During the `tspan` rendering, the `text` bbox will be used instead
of the `tspan` bbox itself. This is the correct behaviour by the SVG spec.
- (cairo-backend) `font-family` parsing.
- (usvg) `filter:none` processing.
- (usvg) `text` inside `text` processing.
- (usvg) Endless loop during `use` resolving.
- (usvg) Endless loop when SVG has indirect recursive `xlink:href` links.
- (usvg) Endless loop when SVG has recursive `marker-*` links.
- (usvg) Panic during `use` resolving.
- (usvg) Panic during inherited attributes resolving.
- (usvg) Groups regrouping.
- (usvg) `dx`/`dy` processing on `text`.
- (usvg) `textAnchor` resolving.
- (usvg) Ignore `fill-rule` on `text`.
- (svgtypes) Style with comments parsing.
- (roxmltree) Namespaces resolving.
## [0.5.0] - 2019-01-04
### Added
- `marker` support.
- Partial `baseline-shift` support.
- `letter-spacing` support.
- (qt-backend) `word-spacing` support.
Does not work on the cairo backend.
- tools/explorer-thumbnailer
- tools/kde-dolphin-thumbnailer
### Fixed
- Object bounding box calculation.
- Pattern scaling.
- Nested `objectBoundigBox` support.
- (usvg) `color` on `use` resolving.
- (usvg) `offset` attribute resolving inside the `stop` element.
- (usvg) Ungrouping of groups with non-inheritable attributes.
- (usvg) `rotate` attribute resolving.
- (usvg) Paths without stroke and fill will no longer be removed.
Required for a proper bbox resolving.
- (usvg) Coordinates resolving when units are `userSpaceOnUse`.
- (usvg) Groups regrouping. Caused an incorrect rendering of `clipPath`
that had `filter` on a child.
- (usvg) Style attributes resolving on the root `svg` element.
- (usvg) `SmoothCurveTo` and `SmoothQuadratic` conversion.
- (usvg) `symbol` resolving.
- (cairo-backend) Font ascent calculation.
- (qt-backend) Stroking of LineTo specified as CurveTo.
- (svgdom) `stroke-miterlimit` attribute parsing.
- (svgdom) `length` and `number` attribute types parsing.
- (svgdom) `offset` attribute parsing.
- (svgdom) IRI resolving order when SVG has duplicated ID's.
## [0.4.0] - 2018-12-13
### Added
- (resvg) Initial filters support.
- (resvg) Nested `clipPath` and `mask` support.
- (resvg) MSVC support.
- (rendersvg) `font-family`, `font-size` and `languages` to args.
- (usvg) `systemLanguage` attribute support.
- (usvg) Default font family and size is configurable now.
- (c-api) `RESVG_ERROR_PARSING_FAILED`.
- (c-api) `font_family`, `font_size` and `languages` to `resvg_options`.
- (qt-api) `ResvgRenderer::setDevicePixelRatio`.
### Changed
- (rendersvg) Use `gumdrop` instead of `getopts`.
- (c-api) Qt wrapper is header-only now.
### Fixed
- (cairo-backend) Text layout.
- (cairo-backend) Rendering of a zero length subpath with a square cap.
- (qt-backend) Transform retrieving via Qt bindings.
- (resvg) Recursive SVG images via `image` tag.
- (resvg) Bbox calculation of the text with rotate.
- (resvg) Invisible elements processing.
- (qt-api) SVG from QByteArray loading when data is invalid.
- (usvg) `display` attribute processing.
- (usvg) Recursive `mask` resolving.
- (usvg) `inherit` attribute value resolving.
- (svgdom) XML namespaces resolving.
### Removed
- (rendersvg) `failure` dependency.
## [0.3.0] - 2018-05-23
### Added
- (c-api) `resvg_is_image_empty`.
- (c-api) `resvg_error` enum.
- (c-api) Qt wrapper.
- (resvg) Advanced text layout support (lists of x, y, dx, dy and rotate).
- (resvg) SVG support for `image` element.
- (usvg) `symbol` element support.
- (usvg) Nested `svg` elements support.
- (usvg) Paint fallback resolving.
- (usvg) Bbox validation for shapes that use painting servers.
- (svgdom) Elements from ENTITY resolving.
### Changed
- (c-api) `resvg_parse_tree_from_file`, `resvg_parse_tree_from_data`
`resvg_cairo_render_to_image` and `resvg_qt_render_to_image`
will return an error code now.
- (cairo-backend) Use `gdk-pixbuf` crate instead of `image`.
- (resvg) `Render::render_to_image` and `Render::render_node_to_image` will return
`Option` and not `Result` now.
- (resvg) New geometry primitives implementation.
- (resvg) Rename `render_*` modules to `backend_`.
- (rendersvg) Use `getopts` instead of `clap` to reduce the executable size.
- (svgtypes) `StreamExt::parse_iri` and `StreamExt::parse_func_iri` will parse
not only well-formed data now.
### Fixed
- (qt-backend) Gradient with `objectBoundingBox` rendering.
- (qt-backend) Text bounding box detection during the rendering.
- (cairo-backend) `image` element clipping.
- (cairo-backend) Layers management.
- (c-api) `resvg_get_node_transform` will return a correct transform now.
- (resvg) `text-decoration` thickness.
- (resvg) `pattern` scaling.
- (resvg) `image` without size rendering.
- (usvg) Panic during `visibility` resolving.
- (usvg) Gradients with one stop resolving.
- (usvg) `use` attributes resolving.
- (usvg) `clipPath` and `mask` attributes resolving.
- (usvg) `offset` attribute in `stop` element resolving.
- (usvg) Incorrect `font-size` attribute resolving.
- (usvg) Gradient stops resolving.
- (usvg) `switch` element resolving.
- (svgdom) Mixed `xml:space` processing.
- (svgtypes) `Paint::from_span` poor performance.
### Removed
- (c-api) `resvg_error_msg_destroy`.
- (resvg) `parse_rtree_*` methods. Use `usvg::Tree::from_` instead.
- (resvg) `Error`.
## [0.2.0] - 2018-04-24
### Added
- (svg) Partial `clipPath` support.
- (svg) Partial `mask` support.
- (svg) Partial `pattern` support.
- (svg) `preserveAspectRatio` support.
- (svg) Check that an external image is PNG or JPEG.
- (rendersvg) Added `--query-all` and `--export-id` arguments to render SVG items by ID.
- (rendersvg) Added `--perf` argument for a simple performance stats.
### Changed
- (resvg) API is completely new.
### Fixed
- `font-size` attribute inheritance during `use` resolving.
[Unreleased]: https://github.com/RazrFalcon/resvg/compare/v0.44.0...HEAD
[0.44.0]: https://github.com/RazrFalcon/resvg/compare/v0.43.0...v0.44.0
[0.43.0]: https://github.com/RazrFalcon/resvg/compare/v0.42.0...v0.43.0
[0.42.0]: https://github.com/RazrFalcon/resvg/compare/v0.41.0...v0.42.0
[0.41.0]: https://github.com/RazrFalcon/resvg/compare/v0.40.0...v0.41.0
[0.40.0]: https://github.com/RazrFalcon/resvg/compare/v0.39.0...v0.40.0
[0.39.0]: https://github.com/RazrFalcon/resvg/compare/v0.38.0...v0.39.0
[0.38.0]: https://github.com/RazrFalcon/resvg/compare/v0.37.0...v0.38.0
[0.37.0]: https://github.com/RazrFalcon/resvg/compare/v0.36.0...v0.37.0
[0.36.0]: https://github.com/RazrFalcon/resvg/compare/v0.35.0...v0.36.0
[0.35.0]: https://github.com/RazrFalcon/resvg/compare/v0.34.1...v0.35.0
[0.34.1]: https://github.com/RazrFalcon/resvg/compare/v0.34.0...v0.34.1
[0.34.0]: https://github.com/RazrFalcon/resvg/compare/v0.33.0...v0.34.0
[0.33.0]: https://github.com/RazrFalcon/resvg/compare/v0.32.0...v0.33.0
[0.32.0]: https://github.com/RazrFalcon/resvg/compare/v0.31.1...v0.32.0
[0.31.1]: https://github.com/RazrFalcon/resvg/compare/v0.31.0...v0.31.1
[0.31.0]: https://github.com/RazrFalcon/resvg/compare/v0.30.0...v0.31.0
[0.30.0]: https://github.com/RazrFalcon/resvg/compare/v0.29.0...v0.30.0
[0.29.0]: https://github.com/RazrFalcon/resvg/compare/v0.28.0...v0.29.0
[0.28.0]: https://github.com/RazrFalcon/resvg/compare/v0.27.0...v0.28.0
[0.27.0]: https://github.com/RazrFalcon/resvg/compare/v0.26.1...v0.27.0
[0.26.1]: https://github.com/RazrFalcon/resvg/compare/v0.26.0...v0.26.1
[0.26.0]: https://github.com/RazrFalcon/resvg/compare/v0.25.0...v0.26.0
[0.25.0]: https://github.com/RazrFalcon/resvg/compare/v0.24.0...v0.25.0
[0.24.0]: https://github.com/RazrFalcon/resvg/compare/v0.23.0...v0.24.0
[0.23.0]: https://github.com/RazrFalcon/resvg/compare/v0.22.0...v0.23.0
[0.22.0]: https://github.com/RazrFalcon/resvg/compare/v0.21.0...v0.22.0
[0.21.0]: https://github.com/RazrFalcon/resvg/compare/v0.20.0...v0.21.0
[0.20.0]: https://github.com/RazrFalcon/resvg/compare/v0.19.0...v0.20.0
[0.19.0]: https://github.com/RazrFalcon/resvg/compare/v0.18.0...v0.19.0
[0.18.0]: https://github.com/RazrFalcon/resvg/compare/v0.17.0...v0.18.0
[0.17.0]: https://github.com/RazrFalcon/resvg/compare/v0.16.0...v0.17.0
[0.16.0]: https://github.com/RazrFalcon/resvg/compare/v0.15.0...v0.16.0
[0.15.0]: https://github.com/RazrFalcon/resvg/compare/v0.14.1...v0.15.0
[0.14.1]: https://github.com/RazrFalcon/resvg/compare/v0.14.0...v0.14.1
[0.14.0]: https://github.com/RazrFalcon/resvg/compare/v0.13.1...v0.14.0
[0.13.1]: https://github.com/RazrFalcon/resvg/compare/v0.13.0...v0.13.1
[0.13.0]: https://github.com/RazrFalcon/resvg/compare/v0.12.0...v0.13.0
[0.12.0]: https://github.com/RazrFalcon/resvg/compare/v0.11.0...v0.12.0
[0.11.0]: https://github.com/RazrFalcon/resvg/compare/v0.10.0...v0.11.0
[0.10.0]: https://github.com/RazrFalcon/resvg/compare/v0.9.1...v0.10.0
[0.9.1]: https://github.com/RazrFalcon/resvg/compare/v0.9.0...v0.9.1
[0.9.0]: https://github.com/RazrFalcon/resvg/compare/v0.8.0...v0.9.0
[0.8.0]: https://github.com/RazrFalcon/resvg/compare/v0.7.0...v0.8.0
[0.7.0]: https://github.com/RazrFalcon/resvg/compare/v0.6.1...v0.7.0
[0.6.1]: https://github.com/RazrFalcon/resvg/compare/v0.6.0...v0.6.1
[0.6.0]: https://github.com/RazrFalcon/resvg/compare/v0.5.0...v0.6.0
[0.5.0]: https://github.com/RazrFalcon/resvg/compare/v0.4.0...v0.5.0
[0.4.0]: https://github.com/RazrFalcon/resvg/compare/v0.3.0...v0.4.0
[0.3.0]: https://github.com/RazrFalcon/resvg/compare/v0.2.0...v0.3.0
[0.2.0]: https://github.com/RazrFalcon/resvg/compare/v0.1.0...v0.2.0
resvg-0.44.0/Cargo.lock 0000664 0000000 0000000 00000031243 14675720665 0014657 0 ustar 00root root 0000000 0000000 # This file is automatically @generated by Cargo.
# It is not intended for manual editing.
version = 3
[[package]]
name = "adler2"
version = "2.0.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "512761e0bb2578dd7380c6baaa0f4ce03e84f95e960231d1dec8bf4d7d6e2627"
[[package]]
name = "arrayref"
version = "0.3.9"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "76a2e8124351fda1ef8aaaa3bbd7ebbcb486bbcd4225aca0aa0d84bb2db8fecb"
[[package]]
name = "arrayvec"
version = "0.7.6"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "7c02d123df017efcdfbd739ef81735b36c5ba83ec3c59c80a9d7ecc718f92e50"
[[package]]
name = "base64"
version = "0.22.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "72b3254f16251a8381aa12e40e3c4d2f0199f8c6508fbecb9d91f575e0fbb8c6"
[[package]]
name = "bitflags"
version = "1.3.2"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "bef38d45163c2f1dde094a7dfd33ccf595c92905c8f8f4fdc18d06fb1037718a"
[[package]]
name = "bitflags"
version = "2.6.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "b048fb63fd8b5923fc5aa7b340d8e156aec7ec02f0c78fa8a6ddc2613f6f71de"
[[package]]
name = "bytemuck"
version = "1.18.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "94bbb0ad554ad961ddc5da507a12a29b14e4ae5bda06b19f575a3e6079d2e2ae"
[[package]]
name = "byteorder-lite"
version = "0.1.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "8f1fe948ff07f4bd06c30984e69f5b4899c516a3ef74f34df92a2df2ab535495"
[[package]]
name = "cfg-if"
version = "1.0.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "baf1de4339761588bc0619e3cbc0120ee582ebb74b53b4efbf79117bd2da40fd"
[[package]]
name = "color_quant"
version = "1.1.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "3d7b894f5411737b7867f4827955924d7c254fc9f4d91a6aad6b097804b1018b"
[[package]]
name = "core_maths"
version = "0.1.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "e3b02505ccb8c50b0aa21ace0fc08c3e53adebd4e58caa18a36152803c7709a3"
dependencies = [
"libm",
]
[[package]]
name = "crc32fast"
version = "1.4.2"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "a97769d94ddab943e4510d138150169a2758b5ef3eb191a9ee688de3e23ef7b3"
dependencies = [
"cfg-if",
]
[[package]]
name = "data-url"
version = "0.3.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "5c297a1c74b71ae29df00c3e22dd9534821d60eb9af5a0192823fa2acea70c2a"
[[package]]
name = "fdeflate"
version = "0.3.5"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "d8090f921a24b04994d9929e204f50b498a33ea6ba559ffaa05e04f7ee7fb5ab"
dependencies = [
"simd-adler32",
]
[[package]]
name = "flate2"
version = "1.0.34"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "a1b589b4dc103969ad3cf85c950899926ec64300a1a46d76c03a6072957036f0"
dependencies = [
"crc32fast",
"miniz_oxide",
]
[[package]]
name = "float-cmp"
version = "0.9.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "98de4bbd547a563b716d8dfa9aad1cb19bfab00f4fa09a6a4ed21dbcf44ce9c4"
[[package]]
name = "fontconfig-parser"
version = "0.5.7"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "c1fcfcd44ca6e90c921fee9fa665d530b21ef1327a4c1a6c5250ea44b776ada7"
dependencies = [
"roxmltree",
]
[[package]]
name = "fontdb"
version = "0.22.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "a3a6f9af55fb97ad673fb7a69533eb2f967648a06fa21f8c9bb2cd6d33975716"
dependencies = [
"fontconfig-parser",
"log",
"memmap2",
"slotmap",
"tinyvec",
"ttf-parser",
]
[[package]]
name = "gif"
version = "0.13.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "3fb2d69b19215e18bb912fa30f7ce15846e301408695e44e0ef719f1da9e19f2"
dependencies = [
"color_quant",
"weezl",
]
[[package]]
name = "image-webp"
version = "0.1.3"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "f79afb8cbee2ef20f59ccd477a218c12a93943d075b492015ecb1bb81f8ee904"
dependencies = [
"byteorder-lite",
"quick-error",
]
[[package]]
name = "imagesize"
version = "0.13.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "edcd27d72f2f071c64249075f42e205ff93c9a4c5f6c6da53e79ed9f9832c285"
[[package]]
name = "kurbo"
version = "0.11.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "89234b2cc610a7dd927ebde6b41dd1a5d4214cffaef4cf1fb2195d592f92518f"
dependencies = [
"arrayvec",
"smallvec",
]
[[package]]
name = "libc"
version = "0.2.159"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "561d97a539a36e26a9a5fad1ea11a3039a67714694aaa379433e580854bc3dc5"
[[package]]
name = "libm"
version = "0.2.8"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "4ec2a862134d2a7d32d7983ddcdd1c4923530833c9f2ea1a44fc5fa473989058"
[[package]]
name = "log"
version = "0.4.22"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "a7a70ba024b9dc04c27ea2f0c0548feb474ec5c54bba33a7f72f873a39d07b24"
[[package]]
name = "memmap2"
version = "0.9.5"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "fd3f7eed9d3848f8b98834af67102b720745c4ec028fcd0aa0239277e7de374f"
dependencies = [
"libc",
]
[[package]]
name = "miniz_oxide"
version = "0.8.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "e2d80299ef12ff69b16a84bb182e3b9df68b5a91574d3d4fa6e41b65deec4df1"
dependencies = [
"adler2",
"simd-adler32",
]
[[package]]
name = "once_cell"
version = "1.19.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "3fdb12b2476b595f9358c5161aa467c2438859caa136dec86c26fdd2efe17b92"
[[package]]
name = "pico-args"
version = "0.5.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "5be167a7af36ee22fe3115051bc51f6e6c7054c9348e28deb4f49bd6f705a315"
[[package]]
name = "png"
version = "0.17.14"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "52f9d46a34a05a6a57566bc2bfae066ef07585a6e3fa30fbbdff5936380623f0"
dependencies = [
"bitflags 1.3.2",
"crc32fast",
"fdeflate",
"flate2",
"miniz_oxide",
]
[[package]]
name = "quick-error"
version = "2.0.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "a993555f31e5a609f617c12db6250dedcac1b0a85076912c436e6fc9b2c8e6a3"
[[package]]
name = "resvg"
version = "0.44.0"
dependencies = [
"gif",
"image-webp",
"log",
"once_cell",
"pico-args",
"png",
"rgb",
"svgtypes",
"tiny-skia",
"usvg",
"zune-jpeg",
]
[[package]]
name = "resvg-capi"
version = "0.44.0"
dependencies = [
"log",
"resvg",
]
[[package]]
name = "rgb"
version = "0.8.50"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "57397d16646700483b67d2dd6511d79318f9d057fdbd21a4066aeac8b41d310a"
dependencies = [
"bytemuck",
]
[[package]]
name = "roxmltree"
version = "0.20.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "6c20b6793b5c2fa6553b250154b78d6d0db37e72700ae35fad9387a46f487c97"
[[package]]
name = "rustybuzz"
version = "0.18.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "c85d1ccd519e61834798eb52c4e886e8c2d7d698dd3d6ce0b1b47eb8557f1181"
dependencies = [
"bitflags 2.6.0",
"bytemuck",
"core_maths",
"log",
"smallvec",
"ttf-parser",
"unicode-bidi-mirroring",
"unicode-ccc",
"unicode-properties",
"unicode-script",
]
[[package]]
name = "simd-adler32"
version = "0.3.7"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "d66dc143e6b11c1eddc06d5c423cfc97062865baf299914ab64caa38182078fe"
[[package]]
name = "simplecss"
version = "0.2.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "a11be7c62927d9427e9f40f3444d5499d868648e2edbc4e2116de69e7ec0e89d"
dependencies = [
"log",
]
[[package]]
name = "siphasher"
version = "1.0.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "56199f7ddabf13fe5074ce809e7d3f42b42ae711800501b5b16ea82ad029c39d"
[[package]]
name = "slotmap"
version = "1.0.7"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "dbff4acf519f630b3a3ddcfaea6c06b42174d9a44bc70c620e9ed1649d58b82a"
dependencies = [
"version_check",
]
[[package]]
name = "smallvec"
version = "1.13.2"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "3c5e1a9a646d36c3599cd173a41282daf47c44583ad367b8e6837255952e5c67"
[[package]]
name = "strict-num"
version = "0.1.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "6637bab7722d379c8b41ba849228d680cc12d0a45ba1fa2b48f2a30577a06731"
dependencies = [
"float-cmp",
]
[[package]]
name = "svgtypes"
version = "0.15.2"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "794de53cc48eaabeed0ab6a3404a65f40b3e38c067e4435883a65d2aa4ca000e"
dependencies = [
"kurbo",
"siphasher",
]
[[package]]
name = "tiny-skia"
version = "0.11.4"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "83d13394d44dae3207b52a326c0c85a8bf87f1541f23b0d143811088497b09ab"
dependencies = [
"arrayref",
"arrayvec",
"bytemuck",
"cfg-if",
"log",
"png",
"tiny-skia-path",
]
[[package]]
name = "tiny-skia-path"
version = "0.11.4"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "9c9e7fc0c2e86a30b117d0462aa261b72b7a99b7ebd7deb3a14ceda95c5bdc93"
dependencies = [
"arrayref",
"bytemuck",
"strict-num",
]
[[package]]
name = "tinyvec"
version = "1.8.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "445e881f4f6d382d5f27c034e25eb92edd7c784ceab92a0937db7f2e9471b938"
dependencies = [
"tinyvec_macros",
]
[[package]]
name = "tinyvec_macros"
version = "0.1.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "1f3ccbac311fea05f86f61904b462b55fb3df8837a366dfc601a0161d0532f20"
[[package]]
name = "ttf-parser"
version = "0.24.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "5be21190ff5d38e8b4a2d3b6a3ae57f612cc39c96e83cedeaf7abc338a8bac4a"
dependencies = [
"core_maths",
]
[[package]]
name = "unicode-bidi"
version = "0.3.15"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "08f95100a766bf4f8f28f90d77e0a5461bbdb219042e7679bebe79004fed8d75"
[[package]]
name = "unicode-bidi-mirroring"
version = "0.3.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "64af057ad7466495ca113126be61838d8af947f41d93a949980b2389a118082f"
[[package]]
name = "unicode-ccc"
version = "0.3.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "260bc6647b3893a9a90668360803a15f96b85a5257b1c3a0c3daf6ae2496de42"
[[package]]
name = "unicode-properties"
version = "0.1.2"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "52ea75f83c0137a9b98608359a5f1af8144876eb67bcb1ce837368e906a9f524"
[[package]]
name = "unicode-script"
version = "0.5.7"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "9fb421b350c9aff471779e262955939f565ec18b86c15364e6bdf0d662ca7c1f"
[[package]]
name = "unicode-vo"
version = "0.1.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "b1d386ff53b415b7fe27b50bb44679e2cc4660272694b7b6f3326d8480823a94"
[[package]]
name = "usvg"
version = "0.44.0"
dependencies = [
"base64",
"data-url",
"flate2",
"fontdb",
"imagesize",
"kurbo",
"log",
"once_cell",
"pico-args",
"roxmltree",
"rustybuzz",
"simplecss",
"siphasher",
"strict-num",
"svgtypes",
"tiny-skia-path",
"unicode-bidi",
"unicode-script",
"unicode-vo",
"xmlwriter",
]
[[package]]
name = "version_check"
version = "0.9.5"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "0b928f33d975fc6ad9f86c8f283853ad26bdd5b10b7f1542aa2fa15e2289105a"
[[package]]
name = "weezl"
version = "0.1.8"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "53a85b86a771b1c87058196170769dd264f66c0782acf1ae6cc51bfd64b39082"
[[package]]
name = "xmlwriter"
version = "0.1.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "ec7a2a501ed189703dba8b08142f057e887dfc4b2cc4db2d343ac6376ba3e0b9"
[[package]]
name = "zune-core"
version = "0.4.12"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "3f423a2c17029964870cfaabb1f13dfab7d092a62a29a89264f4d36990ca414a"
[[package]]
name = "zune-jpeg"
version = "0.4.13"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "16099418600b4d8f028622f73ff6e3deaabdff330fb9a2a131dea781ee8b0768"
dependencies = [
"zune-core",
]
resvg-0.44.0/Cargo.toml 0000664 0000000 0000000 00000000207 14675720665 0014676 0 ustar 00root root 0000000 0000000 [workspace]
members = [
"crates/resvg",
"crates/usvg",
"crates/c-api",
]
default-members = ["crates/resvg"]
resolver = "2"
resvg-0.44.0/LICENSE.txt 0000664 0000000 0000000 00000040526 14675720665 0014601 0 ustar 00root root 0000000 0000000 Mozilla Public License Version 2.0
==================================
1. Definitions
--------------
1.1. "Contributor"
means each individual or legal entity that creates, contributes to
the creation of, or owns Covered Software.
1.2. "Contributor Version"
means the combination of the Contributions of others (if any) used
by a Contributor and that particular Contributor's Contribution.
1.3. "Contribution"
means Covered Software of a particular Contributor.
1.4. "Covered Software"
means Source Code Form to which the initial Contributor has attached
the notice in Exhibit A, the Executable Form of such Source Code
Form, and Modifications of such Source Code Form, in each case
including portions thereof.
1.5. "Incompatible With Secondary Licenses"
means
(a) that the initial Contributor has attached the notice described
in Exhibit B to the Covered Software; or
(b) that the Covered Software was made available under the terms of
version 1.1 or earlier of the License, but not also under the
terms of a Secondary License.
1.6. "Executable Form"
means any form of the work other than Source Code Form.
1.7. "Larger Work"
means a work that combines Covered Software with other material, in
a separate file or files, that is not Covered Software.
1.8. "License"
means this document.
1.9. "Licensable"
means having the right to grant, to the maximum extent possible,
whether at the time of the initial grant or subsequently, any and
all of the rights conveyed by this License.
1.10. "Modifications"
means any of the following:
(a) any file in Source Code Form that results from an addition to,
deletion from, or modification of the contents of Covered
Software; or
(b) any new file in Source Code Form that contains any Covered
Software.
1.11. "Patent Claims" of a Contributor
means any patent claim(s), including without limitation, method,
process, and apparatus claims, in any patent Licensable by such
Contributor that would be infringed, but for the grant of the
License, by the making, using, selling, offering for sale, having
made, import, or transfer of either its Contributions or its
Contributor Version.
1.12. "Secondary License"
means either the GNU General Public License, Version 2.0, the GNU
Lesser General Public License, Version 2.1, the GNU Affero General
Public License, Version 3.0, or any later versions of those
licenses.
1.13. "Source Code Form"
means the form of the work preferred for making modifications.
1.14. "You" (or "Your")
means an individual or a legal entity exercising rights under this
License. For legal entities, "You" includes any entity that
controls, is controlled by, or is under common control with You. For
purposes of this definition, "control" means (a) the power, direct
or indirect, to cause the direction or management of such entity,
whether by contract or otherwise, or (b) ownership of more than
fifty percent (50%) of the outstanding shares or beneficial
ownership of such entity.
2. License Grants and Conditions
--------------------------------
2.1. Grants
Each Contributor hereby grants You a world-wide, royalty-free,
non-exclusive license:
(a) under intellectual property rights (other than patent or trademark)
Licensable by such Contributor to use, reproduce, make available,
modify, display, perform, distribute, and otherwise exploit its
Contributions, either on an unmodified basis, with Modifications, or
as part of a Larger Work; and
(b) under Patent Claims of such Contributor to make, use, sell, offer
for sale, have made, import, and otherwise transfer either its
Contributions or its Contributor Version.
2.2. Effective Date
The licenses granted in Section 2.1 with respect to any Contribution
become effective for each Contribution on the date the Contributor first
distributes such Contribution.
2.3. Limitations on Grant Scope
The licenses granted in this Section 2 are the only rights granted under
this License. No additional rights or licenses will be implied from the
distribution or licensing of Covered Software under this License.
Notwithstanding Section 2.1(b) above, no patent license is granted by a
Contributor:
(a) for any code that a Contributor has removed from Covered Software;
or
(b) for infringements caused by: (i) Your and any other third party's
modifications of Covered Software, or (ii) the combination of its
Contributions with other software (except as part of its Contributor
Version); or
(c) under Patent Claims infringed by Covered Software in the absence of
its Contributions.
This License does not grant any rights in the trademarks, service marks,
or logos of any Contributor (except as may be necessary to comply with
the notice requirements in Section 3.4).
2.4. Subsequent Licenses
No Contributor makes additional grants as a result of Your choice to
distribute the Covered Software under a subsequent version of this
License (see Section 10.2) or under the terms of a Secondary License (if
permitted under the terms of Section 3.3).
2.5. Representation
Each Contributor represents that the Contributor believes its
Contributions are its original creation(s) or it has sufficient rights
to grant the rights to its Contributions conveyed by this License.
2.6. Fair Use
This License is not intended to limit any rights You have under
applicable copyright doctrines of fair use, fair dealing, or other
equivalents.
2.7. Conditions
Sections 3.1, 3.2, 3.3, and 3.4 are conditions of the licenses granted
in Section 2.1.
3. Responsibilities
-------------------
3.1. Distribution of Source Form
All distribution of Covered Software in Source Code Form, including any
Modifications that You create or to which You contribute, must be under
the terms of this License. You must inform recipients that the Source
Code Form of the Covered Software is governed by the terms of this
License, and how they can obtain a copy of this License. You may not
attempt to alter or restrict the recipients' rights in the Source Code
Form.
3.2. Distribution of Executable Form
If You distribute Covered Software in Executable Form then:
(a) such Covered Software must also be made available in Source Code
Form, as described in Section 3.1, and You must inform recipients of
the Executable Form how they can obtain a copy of such Source Code
Form by reasonable means in a timely manner, at a charge no more
than the cost of distribution to the recipient; and
(b) You may distribute such Executable Form under the terms of this
License, or sublicense it under different terms, provided that the
license for the Executable Form does not attempt to limit or alter
the recipients' rights in the Source Code Form under this License.
3.3. Distribution of a Larger Work
You may create and distribute a Larger Work under terms of Your choice,
provided that You also comply with the requirements of this License for
the Covered Software. If the Larger Work is a combination of Covered
Software with a work governed by one or more Secondary Licenses, and the
Covered Software is not Incompatible With Secondary Licenses, this
License permits You to additionally distribute such Covered Software
under the terms of such Secondary License(s), so that the recipient of
the Larger Work may, at their option, further distribute the Covered
Software under the terms of either this License or such Secondary
License(s).
3.4. Notices
You may not remove or alter the substance of any license notices
(including copyright notices, patent notices, disclaimers of warranty,
or limitations of liability) contained within the Source Code Form of
the Covered Software, except that You may alter any license notices to
the extent required to remedy known factual inaccuracies.
3.5. Application of Additional Terms
You may choose to offer, and to charge a fee for, warranty, support,
indemnity or liability obligations to one or more recipients of Covered
Software. However, You may do so only on Your own behalf, and not on
behalf of any Contributor. You must make it absolutely clear that any
such warranty, support, indemnity, or liability obligation is offered by
You alone, and You hereby agree to indemnify every Contributor for any
liability incurred by such Contributor as a result of warranty, support,
indemnity or liability terms You offer. You may include additional
disclaimers of warranty and limitations of liability specific to any
jurisdiction.
4. Inability to Comply Due to Statute or Regulation
---------------------------------------------------
If it is impossible for You to comply with any of the terms of this
License with respect to some or all of the Covered Software due to
statute, judicial order, or regulation then You must: (a) comply with
the terms of this License to the maximum extent possible; and (b)
describe the limitations and the code they affect. Such description must
be placed in a text file included with all distributions of the Covered
Software under this License. Except to the extent prohibited by statute
or regulation, such description must be sufficiently detailed for a
recipient of ordinary skill to be able to understand it.
5. Termination
--------------
5.1. The rights granted under this License will terminate automatically
if You fail to comply with any of its terms. However, if You become
compliant, then the rights granted under this License from a particular
Contributor are reinstated (a) provisionally, unless and until such
Contributor explicitly and finally terminates Your grants, and (b) on an
ongoing basis, if such Contributor fails to notify You of the
non-compliance by some reasonable means prior to 60 days after You have
come back into compliance. Moreover, Your grants from a particular
Contributor are reinstated on an ongoing basis if such Contributor
notifies You of the non-compliance by some reasonable means, this is the
first time You have received notice of non-compliance with this License
from such Contributor, and You become compliant prior to 30 days after
Your receipt of the notice.
5.2. If You initiate litigation against any entity by asserting a patent
infringement claim (excluding declaratory judgment actions,
counter-claims, and cross-claims) alleging that a Contributor Version
directly or indirectly infringes any patent, then the rights granted to
You by any and all Contributors for the Covered Software under Section
2.1 of this License shall terminate.
5.3. In the event of termination under Sections 5.1 or 5.2 above, all
end user license agreements (excluding distributors and resellers) which
have been validly granted by You or Your distributors under this License
prior to termination shall survive termination.
************************************************************************
* *
* 6. Disclaimer of Warranty *
* ------------------------- *
* *
* Covered Software is provided under this License on an "as is" *
* basis, without warranty of any kind, either expressed, implied, or *
* statutory, including, without limitation, warranties that the *
* Covered Software is free of defects, merchantable, fit for a *
* particular purpose or non-infringing. The entire risk as to the *
* quality and performance of the Covered Software is with You. *
* Should any Covered Software prove defective in any respect, You *
* (not any Contributor) assume the cost of any necessary servicing, *
* repair, or correction. This disclaimer of warranty constitutes an *
* essential part of this License. No use of any Covered Software is *
* authorized under this License except under this disclaimer. *
* *
************************************************************************
************************************************************************
* *
* 7. Limitation of Liability *
* -------------------------- *
* *
* Under no circumstances and under no legal theory, whether tort *
* (including negligence), contract, or otherwise, shall any *
* Contributor, or anyone who distributes Covered Software as *
* permitted above, be liable to You for any direct, indirect, *
* special, incidental, or consequential damages of any character *
* including, without limitation, damages for lost profits, loss of *
* goodwill, work stoppage, computer failure or malfunction, or any *
* and all other commercial damages or losses, even if such party *
* shall have been informed of the possibility of such damages. This *
* limitation of liability shall not apply to liability for death or *
* personal injury resulting from such party's negligence to the *
* extent applicable law prohibits such limitation. Some *
* jurisdictions do not allow the exclusion or limitation of *
* incidental or consequential damages, so this exclusion and *
* limitation may not apply to You. *
* *
************************************************************************
8. Litigation
-------------
Any litigation relating to this License may be brought only in the
courts of a jurisdiction where the defendant maintains its principal
place of business and such litigation shall be governed by laws of that
jurisdiction, without reference to its conflict-of-law provisions.
Nothing in this Section shall prevent a party's ability to bring
cross-claims or counter-claims.
9. Miscellaneous
----------------
This License represents the complete agreement concerning the subject
matter hereof. If any provision of this License is held to be
unenforceable, such provision shall be reformed only to the extent
necessary to make it enforceable. Any law or regulation which provides
that the language of a contract shall be construed against the drafter
shall not be used to construe this License against a Contributor.
10. Versions of the License
---------------------------
10.1. New Versions
Mozilla Foundation is the license steward. Except as provided in Section
10.3, no one other than the license steward has the right to modify or
publish new versions of this License. Each version will be given a
distinguishing version number.
10.2. Effect of New Versions
You may distribute the Covered Software under the terms of the version
of the License under which You originally received the Covered Software,
or under the terms of any subsequent version published by the license
steward.
10.3. Modified Versions
If you create software not governed by this License, and you want to
create a new license for such software, you may create and use a
modified version of this License if you rename the license and remove
any references to the name of the license steward (except to note that
such modified license differs from this License).
10.4. Distributing Source Code Form that is Incompatible With Secondary
Licenses
If You choose to distribute Source Code Form that is Incompatible With
Secondary Licenses under the terms of this version of the License, the
notice described in Exhibit B of this License must be attached.
Exhibit A - Source Code Form License Notice
-------------------------------------------
This Source Code Form is subject to the terms of the Mozilla Public
License, v. 2.0. If a copy of the MPL was not distributed with this
file, You can obtain one at http://mozilla.org/MPL/2.0/.
If it is not possible or desirable to put the notice in a particular
file, then You may include the notice in a location (such as a LICENSE
file in a relevant directory) where a recipient would be likely to look
for such a notice.
You may add additional accurate notices of copyright ownership.
Exhibit B - "Incompatible With Secondary Licenses" Notice
---------------------------------------------------------
This Source Code Form is "Incompatible With Secondary Licenses", as
defined by the Mozilla Public License, v. 2.0.
resvg-0.44.0/NOTICE.txt 0000664 0000000 0000000 00000000044 14675720665 0014467 0 ustar 00root root 0000000 0000000 Copyright (c) 2017 Yevhenii Reizner
resvg-0.44.0/README.md 0000664 0000000 0000000 00000015271 14675720665 0014234 0 ustar 00root root 0000000 0000000 ## resvg

[](https://crates.io/crates/resvg)
[](https://docs.rs/resvg)
[](https://www.rust-lang.org)
*resvg* is an [SVG](https://en.wikipedia.org/wiki/Scalable_Vector_Graphics) rendering library.
It can be used as a Rust library, as a C library, and as a CLI application to render static SVG files.
The core idea is to make a fast, small, portable SVG library with the goal to support the whole SVG spec.
## Features
### Designed for edge-cases
SVG is a very complicated format with a large specification (SVG 1.1 is almost 900 pages).
You basically need a web browser to handle all of it. But the truth is that even browsers
fail at this (see [SVG support](https://github.com/RazrFalcon/resvg#svg-support)).
Yes, unlike `resvg`, browsers do support dynamic SVG features like animations and scripting.
But using a browser to render SVG _correctly_ is sadly not an option.
To prove its correctness, `resvg` has a vast test suite that includes around 1600 tests.
And those are only SVG-to-PNG regression tests. This doesn't include tests in `resvg` dependencies.
And the best thing is that `resvg` test suite is available to everyone. It's not tied to `resvg`
in any way. Which should help people who plan to develop their own SVG libraries.
### Safety
It's hard not to mention safety when we talk about Rust and processing of a random input.
And we're talking not only about SVG/XML, but also about CSS, TTF, PNG, JPEG, GIF, and GZIP.
While `resvg` is not the only SVG library written in Rust, it's the only one that
is written completely in Rust. There is no non-Rust code in the final binary.
Moreover, there is almost no `unsafe` code either. Still, some dependencies have some `unsafe` code
and font memory-mapping is inherently `unsafe`, but it's best you can get in terms of memory safety.
However, this doesn't stop at memory safety. `resvg` has extensive checks to prevent endless loops (freezes)
and stack overflows (via recursion).
### Zero bloat
Right now, the `resvg` CLI application is less than 3MB in size and doesn't require any external dependencies.
The binary contains nothing that isn't needed for rendering SVG files.
### Portable
`resvg` is guaranteed to work everywhere where you can compile the Rust itself,
including WASM. There are some rough edges with obscure CPU architectures and
mobile OSs (mainly system fonts loading), but it should be pretty painless otherwise.
### SVG preprocessing
Another major difference from other SVG rendering libraries is that in `resvg`
SVG parsing and rendering are two completely separate steps.
Those steps are also split into two separate libraries: `resvg` and [usvg].
Meaning you can easily write your own renderer on top of `usvg` using any 2D library of your liking.
### Performance
Comparing performance between different SVG rendering libraries is like comparing apples and oranges.
Everyone has a very different set of supported features, languages, build flags, etc...
Anyhow, as `resvg` is written in Rust and uses [tiny-skia] for rendering - it's pretty fast.
There should also still be quite a lot of room for improvement.
### Reproducibility
Since `resvg` doesn't rely on any system libraries it allows us to have reproducible results
on all supported platforms. Meaning if you render an SVG file on x86 Windows and then render it
on ARM macOS - the produced image will be identical. Each pixel would have the same value.
## Limitations
- No animations
There are no plans on implementing them either.
- No native text rendering
`resvg` doesn't rely on any system libraries, which implies that we cannot use native text rendering.
Nevertheless, native text rendering is optimized for small horizontal text, which is not
that common in SVG.
- Unicode-only
It's the 21st century. Text files that aren't UTF-8 encoded are no longer relevant.
## SVG support
`resvg` aims to only support the [static](http://www.w3.org/TR/SVG11/feature#SVG-static)
SVG subset; i.e. no `a`, `script`, `view` or `cursor` elements, no events and no animations.
[SVG 2](https://www.w3.org/TR/SVG2/) support is being worked on.
You can search for relevant issues with the
[svg2 tag](https://github.com/RazrFalcon/resvg/issues?q=is%3Aissue+is%3Aopen+label%3Asvg2)
or our [SVG 2 changelog](https://github.com/RazrFalcon/resvg/blob/master/docs/svg2-changelog.md).
[SVG Tiny 1.2](https://www.w3.org/TR/SVGTiny12/) is not supported and support is also not planned.
Results of the [resvg test suite](https://github.com/RazrFalcon/resvg-test-suite):

SVG 2 only results:

You can find a complete table of supported features
[here](https://razrfalcon.github.io/resvg-test-suite/svg-support-table.html).
It also includes some alternative libraries.
We're not testing against all SVG libraries since many of them are pretty bad.
Some libraries are not on the list because they don't pass the 25% mark.
Such libraries are: wxSvg, LunaSVG and nanosvg.
## resvg project
There is a subtle difference between resvg as a _library_ and resvg as a _project_.
While most users will interact only with the resvg library, it's just a tip of an iceberg.
There are a lot of libraries that I had to write to make resvg possible.
Here are some of them:
- resvg - the actual SVG renderer
- [usvg] - an SVG preprocessor/simplifier
- [tiny-skia] - a [Skia](https://github.com/google/skia) subset ported to Rust
- [rustybuzz] - a [harfbuzz](https://github.com/harfbuzz/harfbuzz) subset ported to Rust
- [ttf-parser] - a TrueType/OpenType font parser
- [fontdb] - a simple, in-memory font database with CSS-like queries
- [roxmltree] - an XML parsing library
- [simplecss] - a pretty decent CSS 2 parser and selector
- [pico-args] - an absolutely minimal, but surprisingly popular command-line arguments parser
So while the resvg _library_ is deceptively small (around 2500 LOC), the resvg _project_
is nearing 75'000 LOC. Which is not that much considering how much resvg does.
It's definitely the smallest option out there.
## License
`resvg` project is licensed under the [MPLv2.0](https://www.mozilla.org/en-US/MPL/).
[usvg]: https://github.com/RazrFalcon/resvg/tree/master/crates/usvg
[rustybuzz]: https://github.com/RazrFalcon/rustybuzz
[tiny-skia]: https://github.com/RazrFalcon/tiny-skia
[ttf-parser]: https://github.com/RazrFalcon/ttf-parser
[roxmltree]: https://github.com/RazrFalcon/roxmltree
[simplecss]: https://github.com/RazrFalcon/simplecss
[fontdb]: https://github.com/RazrFalcon/fontdb
[pico-args]: https://github.com/RazrFalcon/pico-args
resvg-0.44.0/crates/ 0000775 0000000 0000000 00000000000 14675720665 0014230 5 ustar 00root root 0000000 0000000 resvg-0.44.0/crates/c-api/ 0000775 0000000 0000000 00000000000 14675720665 0015221 5 ustar 00root root 0000000 0000000 resvg-0.44.0/crates/c-api/Cargo.toml 0000664 0000000 0000000 00000001600 14675720665 0017146 0 ustar 00root root 0000000 0000000 [package]
name = "resvg-capi"
version = "0.44.0"
authors = ["Yevhenii Reizner "]
keywords = ["svg", "render", "raster", "c-api"]
license = "MPL-2.0"
edition = "2021"
workspace = "../.."
[lib]
name = "resvg"
path = "lib.rs"
crate-type = ["cdylib", "staticlib"]
[dependencies]
log = "0.4"
resvg = { path = "../resvg", default-features = false }
[features]
default = ["text", "system-fonts", "memmap-fonts", "raster-images"]
# enables SVG Text support
# adds around 500KiB to your binary
text = ["resvg/text"]
# enables system fonts loading (only for `text`)
system-fonts = ["resvg/system-fonts"]
# enables font files memmaping for faster loading (only for `text`)
memmap-fonts = ["resvg/memmap-fonts"]
raster-images = ["resvg/raster-images"]
capi = []
[package.metadata.capi.header]
generation = false
[package.metadata.capi.install.include]
asset = [{ from="resvg.h" }]
resvg-0.44.0/crates/c-api/README.md 0000664 0000000 0000000 00000000436 14675720665 0016503 0 ustar 00root root 0000000 0000000 # C API for resvg
## Build
```sh
cargo build --release
```
This will produce dynamic and static C libraries that can be found at `../target/release`.
## Header generation
The `resvg.h` is generated via [cbindgen](https://github.com/eqrion/cbindgen)
and then manually edited a bit.
resvg-0.44.0/crates/c-api/ResvgQt.h 0000664 0000000 0000000 00000033133 14675720665 0016770 0 ustar 00root root 0000000 0000000 /*
* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/.
*/
/**
* @file ResvgQt.h
*
* An idiomatic Qt API for resvg.
*/
#ifndef RESVG_QT_H
#define RESVG_QT_H
#define RESVG_QT_MAJOR_VERSION 0
#define RESVG_QT_MINOR_VERSION 44
#define RESVG_QT_PATCH_VERSION 0
#define RESVG_QT_VERSION "0.44.0"
#include
#include
#include
#include
#include
#include
#include
#include
#include
#include
#include
#include
namespace ResvgPrivate {
class Data
{
public:
~Data()
{
clear();
}
void reset()
{
clear();
}
resvg_render_tree *tree = nullptr;
QSizeF size;
QString errMsg;
private:
void clear()
{
// No need to deallocate opt.font_family, because it is a constant.
if (tree) {
resvg_tree_destroy(tree);
tree = nullptr;
}
size = QSizeF();
errMsg = QString();
}
};
static QString errorToString(const int err)
{
switch (err) {
case RESVG_OK :
return QString();
case RESVG_ERROR_NOT_AN_UTF8_STR :
return QLatin1String("The SVG content has not an UTF-8 encoding.");
case RESVG_ERROR_FILE_OPEN_FAILED :
return QLatin1String("Failed to read the file.");
case RESVG_ERROR_MALFORMED_GZIP :
return QLatin1String("Not a GZip compressed data.");
case RESVG_ERROR_ELEMENTS_LIMIT_REACHED :
return QLatin1String("Too many elements.");
case RESVG_ERROR_INVALID_SIZE :
return QLatin1String("SVG doesn't have a valid size.");
case RESVG_ERROR_PARSING_FAILED :
return QLatin1String("Failed to parse an SVG data.");
}
Q_UNREACHABLE();
}
} //ResvgPrivate
/**
* @brief SVG parsing options.
*/
class ResvgOptions {
public:
/**
* @brief Constructs a new options set.
*/
ResvgOptions()
: d(resvg_options_create())
{
// Do not set the default font via QFont::family()
// because it will return a dummy one on Windows.
// See https://github.com/RazrFalcon/resvg/issues/159
setLanguages({ QLocale().bcp47Name() });
}
/**
* @brief Sets a directory that will be used during relative paths resolving.
*
* Expected to be the same as the directory that contains the SVG file,
* but can be set to any.
*
* Default: not set
*/
void setResourcesDir(const QString &path)
{
Q_ASSERT(QFileInfo(path).isDir());
if (path.isEmpty()) {
resvg_options_set_resources_dir(d, nullptr);
} else {
auto pathC = path.toUtf8();
pathC.append('\0');
resvg_options_set_resources_dir(d, pathC.constData());
}
}
/**
* @brief Sets the target DPI.
*
* Impact units conversion.
*
* Default: 96
*/
void setDpi(const float dpi)
{
resvg_options_set_dpi(d, dpi);
}
/**
* @brief Sets the default font family.
*
* Will be used when no `font-family` attribute is set in the SVG.
*
* Default: Times New Roman
*/
void setFontFamily(const QString &family)
{
if (family.isEmpty()) {
return;
}
auto familyC = family.toUtf8();
familyC.append('\0');
resvg_options_set_font_family(d, familyC.constData());
}
/**
* @brief Sets the default font size.
*
* Will be used when no `font-size` attribute is set in the SVG.
*
* Default: 12
*/
void setFontSize(const float size)
{
resvg_options_set_font_size(d, size);
}
/**
* @brief Sets a list of languages.
*
* Will be used to resolve a `systemLanguage` conditional attribute.
*
* Example: en, en-US.
*
* Default: en
*/
void setLanguages(const QStringList &languages)
{
if (languages.isEmpty()) {
resvg_options_set_languages(d, nullptr);
} else {
auto languagesC = languages.join(',').toUtf8();
languagesC.append('\0');
resvg_options_set_languages(d, languagesC.constData());
}
}
/**
* @brief Sets the default shape rendering method.
*
* Will be used when an SVG element's `shape-rendering` property is set to `auto`.
*
* Default: `RESVG_SHAPE_RENDERING_GEOMETRIC_PRECISION`
*/
void setShapeRenderingMode(const resvg_shape_rendering mode)
{
resvg_options_set_shape_rendering_mode(d, mode);
}
/**
* @brief Sets the default text rendering method.
*
* Will be used when an SVG element's `text-rendering` property is set to `auto`.
*
* Default: `RESVG_TEXT_RENDERING_OPTIMIZE_LEGIBILITY`
*/
void setTextRenderingMode(const resvg_text_rendering mode)
{
resvg_options_set_text_rendering_mode(d, mode);
}
/**
* @brief Sets the default image rendering method.
*
* Will be used when an SVG element's `image-rendering` property is set to `auto`.
*
* Default: `RESVG_IMAGE_RENDERING_OPTIMIZE_QUALITY`
*/
void setImageRenderingMode(const resvg_image_rendering mode)
{
resvg_options_set_image_rendering_mode(d, mode);
}
/**
* @brief Loads a font data into the internal fonts database.
*
* Prints a warning into the log when the data is not a valid TrueType font.
*/
void loadFontData(const QByteArray &data)
{
resvg_options_load_font_data(d, data.constData(), data.size());
}
/**
* @brief Loads a font file into the internal fonts database.
*
* Prints a warning into the log when the data is not a valid TrueType font.
*/
bool loadFontFile(const QString &path)
{
auto pathC = path.toUtf8();
pathC.append('\0');
return resvg_options_load_font_file(d, pathC.constData());
}
/**
* @brief Loads system fonts into the internal fonts database.
*
* This method is very IO intensive.
*
* This method should be executed only once per #resvg_options.
*
* The system scanning is not perfect, so some fonts may be omitted.
* Please send a bug report in this case.
*
* Prints warnings into the log.
*/
void loadSystemFonts()
{
resvg_options_load_system_fonts(d);
}
/**
* @brief Destructs options.
*/
~ResvgOptions()
{
resvg_options_destroy(d);
}
friend class ResvgRenderer;
private:
resvg_options * const d;
};
/**
* @brief QSvgRenderer-like wrapper for resvg.
*/
class ResvgRenderer {
public:
/**
* @brief Constructs a new renderer.
*/
ResvgRenderer()
: d(new ResvgPrivate::Data())
{
}
/**
* @brief Constructs a new renderer and loads the contents of the SVG(Z) file.
*/
ResvgRenderer(const QString &filePath, const ResvgOptions &opt)
: d(new ResvgPrivate::Data())
{
load(filePath, opt);
}
/**
* @brief Constructs a new renderer and loads the SVG data.
*/
ResvgRenderer(const QByteArray &data, const ResvgOptions &opt)
: d(new ResvgPrivate::Data())
{
load(data, opt);
}
/**
* @brief Loads the contents of the SVG(Z) file.
*/
bool load(const QString &filePath, const ResvgOptions &opt)
{
// Check for Qt resource path.
if (filePath.startsWith(QLatin1String(":/"))) {
QFile file(filePath);
if (file.open(QFile::ReadOnly))
return load(file.readAll(), opt);
else
return false;
}
d->reset();
auto filePathC = filePath.toUtf8();
filePathC.append('\0');
const auto err = resvg_parse_tree_from_file(filePathC.constData(), opt.d, &d->tree);
if (err != RESVG_OK) {
d->errMsg = ResvgPrivate::errorToString(err);
return false;
}
const auto s = resvg_get_image_size(d->tree);
d->size = QSizeF(s.width, s.height);
return true;
}
/**
* @brief Loads the SVG data.
*/
bool load(const QByteArray &data, const ResvgOptions &opt)
{
d->reset();
const auto err = resvg_parse_tree_from_data(data.constData(), data.size(), opt.d, &d->tree);
if (err != RESVG_OK) {
d->errMsg = ResvgPrivate::errorToString(err);
return false;
}
const auto s = resvg_get_image_size(d->tree);
d->size = QSizeF(s.width, s.height);
return true;
}
/**
* @brief Returns \b true if the file or data were loaded successful.
*/
bool isValid() const
{
return d->tree;
}
/**
* @brief Returns an underling error when #isValid is \b false.
*/
QString errorString() const
{
return d->errMsg;
}
/**
* @brief Checks that underling tree has any nodes.
*
* #ResvgRenderer and #ResvgRenderer constructors
* will set an error only if a file does not exist or it has a non-UTF-8 encoding.
* All other errors will result in an empty tree with a 100x100px size.
*
* @return Returns \b true if tree has no nodes.
*/
bool isEmpty() const
{
if (d->tree)
return resvg_is_image_empty(d->tree);
else
return true;
}
/**
* @brief Returns an SVG size.
*
* The `width` and `height` attributes in SVG.
*/
QSize defaultSize() const
{
return defaultSizeF().toSize();
}
/**
* @brief Returns an SVG size.
*
* The `width` and `height` attributes in SVG.
*/
QSizeF defaultSizeF() const
{
if (d->tree)
return d->size.toSize();
else
return QSizeF();
}
/**
* @brief Returns an SVG viewbox.
*
* `resvg` flattens the `viewbox`, therefore this method returns
* the same value as \b size.
*/
QRect viewBox() const
{
return QRect(0, 0, d->size.width(), d->size.height());
}
/**
* @brief Returns an SVG viewbox.
*
* `resvg` flattens the `viewbox`, therefore this method returns
* the same value as \b size.
*/
QRectF viewBoxF() const
{
return QRectF(0, 0, d->size.width(), d->size.height());
}
/**
* @brief Returns bounding rectangle of the item with the given \b id.
* The transformation matrix of parent elements is not affecting
* the bounds of the element.
*/
QRectF boundsOnElement(const QString &id) const
{
if (!d->tree)
return QRectF();
const auto utf8Str = id.toUtf8();
const auto rawId = utf8Str.constData();
resvg_rect bbox;
if (resvg_get_node_bbox(d->tree, rawId, &bbox))
return QRectF(bbox.x, bbox.y, bbox.width, bbox.height);
return QRectF();
}
/**
* @brief Returns bounding rectangle of a whole image.
*/
QRectF boundingBox() const
{
if (!d->tree)
return QRectF();
resvg_rect bbox;
if (resvg_get_object_bbox(d->tree, &bbox))
return QRectF(bbox.x, bbox.y, bbox.width, bbox.height);
return QRectF();
}
/**
* @brief Returns \b true if element with such an ID exists.
*/
bool elementExists(const QString &id) const
{
if (!d->tree)
return false;
const auto utf8Str = id.toUtf8();
const auto rawId = utf8Str.constData();
return resvg_node_exists(d->tree, rawId);
}
/**
* @brief Returns element's transform.
*/
QTransform transformForElement(const QString &id) const
{
if (!d->tree)
return QTransform();
const auto utf8Str = id.toUtf8();
const auto rawId = utf8Str.constData();
resvg_transform ts;
if (resvg_get_node_transform(d->tree, rawId, &ts))
return QTransform(ts.a, ts.b, ts.c, ts.d, ts.e, ts.f);
return QTransform();
}
// TODO: render node
/**
* @brief Renders the SVG data to \b QImage with a specified \b size.
*
* If \b size is not set, the \b defaultSize() will be used.
*/
QImage renderToImage(const QSize &size = QSize()) const
{
resvg_transform ts = resvg_transform_identity();
if (size.isValid()) {
// TODO: support height too.
auto sizef = defaultSizeF();
const auto newHeight = std::ceil(double(size.width()) * sizef.height() / sizef.width());
ts.a = double(size.width()) / sizef.width();
ts.d = newHeight / sizef.height();
}
auto svgSize = size;
if (svgSize.isEmpty())
svgSize = defaultSize();
QImage qImg(svgSize.width(), svgSize.height(), QImage::Format_ARGB32_Premultiplied);
qImg.fill(Qt::transparent);
resvg_render(d->tree, ts, qImg.width(), qImg.height(), (char*)qImg.bits());
// resvg renders onto the RGBA canvas, while QImage is ARGB.
// std::move is required to call inplace version of rgbSwapped().
return std::move(qImg).rgbSwapped();
}
/**
* @brief Initializes the library log.
*
* Use it if you want to see any warnings.
*
* Must be called only once.
*
* All warnings will be printed to the \b stderr.
*/
static void initLog()
{
resvg_init_log();
}
private:
QScopedPointer d;
};
#endif // RESVG_QT_H
resvg-0.44.0/crates/c-api/cbindgen.toml 0000664 0000000 0000000 00000001260 14675720665 0017666 0 ustar 00root root 0000000 0000000 language = "C"
include_guard = "RESVG_H"
braces = "SameLine"
tab_width = 4
documentation_style = "doxy"
header = """/*
* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/.
*/
/**
* @file resvg.h
*
* resvg C API
*/"""
cpp_compat = true
no_includes = true
sys_includes = ["stdbool.h", "stdint.h"]
style = "type"
[fn]
sort_by = "None"
[enum]
rename_variants = "ScreamingSnakeCase"
prefix_with_name = true
[export]
include = [
"resvg_error",
"resvg_shape_rendering",
"resvg_text_rendering",
"resvg_image_rendering",
]
resvg-0.44.0/crates/c-api/examples/ 0000775 0000000 0000000 00000000000 14675720665 0017037 5 ustar 00root root 0000000 0000000 resvg-0.44.0/crates/c-api/examples/cairo/ 0000775 0000000 0000000 00000000000 14675720665 0020134 5 ustar 00root root 0000000 0000000 resvg-0.44.0/crates/c-api/examples/cairo/Makefile 0000664 0000000 0000000 00000000660 14675720665 0021576 0 ustar 00root root 0000000 0000000 TARGET = example
LIBS = -lm -L../../../../target/debug -lresvg `pkg-config --libs cairo`
CC = gcc
CFLAGS = -g -Wall `pkg-config --cflags cairo` -I../../
.PHONY: default all clean
default: $(TARGET)
all: default
OBJECTS = $(patsubst %.c, %.o, $(wildcard *.c))
%.o: %.c $(CC) $(CFLAGS) -c $< -o $@
.PRECIOUS: $(TARGET) $(OBJECTS)
$(TARGET): $(OBJECTS)
$(CC) $(OBJECTS) -Wall $(LIBS) -o $@
clean:
-rm -f *.o
-rm -f $(TARGET)
resvg-0.44.0/crates/c-api/examples/cairo/README.md 0000664 0000000 0000000 00000000351 14675720665 0021412 0 ustar 00root root 0000000 0000000 A simple example that shows how to use *resvg* through C API to render on a Cairo context.
## Run
```bash
cargo build --manifest-path ../../Cargo.toml
make
LD_LIBRARY_PATH=../../../../target/debug ./example image.svg image.png
```
resvg-0.44.0/crates/c-api/examples/cairo/example.c 0000664 0000000 0000000 00000002660 14675720665 0021737 0 ustar 00root root 0000000 0000000 #include
#include
#include
#include
#include
int main(int argc, char **argv)
{
if (argc != 3)
{
printf("Usage:\n\texample in.svg out.png");
abort();
}
resvg_init_log();
resvg_options *opt = resvg_options_create();
resvg_options_load_system_fonts(opt);
resvg_render_tree *tree;
int err = resvg_parse_tree_from_file(argv[1], opt, &tree);
resvg_options_destroy(opt);
if (err != RESVG_OK)
{
printf("Error id: %i\n", err);
abort();
}
resvg_size size = resvg_get_image_size(tree);
int width = (int)size.width;
int height = (int)size.height;
cairo_surface_t *surface = cairo_image_surface_create(CAIRO_FORMAT_ARGB32, width, height);
/* resvg doesn't support stride, so cairo_surface_t should have no padding */
assert(cairo_image_surface_get_stride(surface) == (int)size.width * 4);
unsigned char *surface_data = cairo_image_surface_get_data(surface);
resvg_render(tree, resvg_transform_identity(), width, height, (char*)surface_data);
/* RGBA -> BGRA */
for (int i = 0; i < width * height * 4; i += 4)
{
unsigned char r = surface_data[i + 0];
surface_data[i + 0] = surface_data[i + 2];
surface_data[i + 2] = r;
}
cairo_surface_write_to_png(surface, argv[2]);
cairo_surface_destroy(surface);
resvg_tree_destroy(tree);
return 0;
}
resvg-0.44.0/crates/c-api/lib.rs 0000664 0000000 0000000 00000063131 14675720665 0016341 0 ustar 00root root 0000000 0000000 // This Source Code Form is subject to the terms of the Mozilla Public
// License, v. 2.0. If a copy of the MPL was not distributed with this
// file, You can obtain one at http://mozilla.org/MPL/2.0/.
//! C bindings.
#![allow(non_camel_case_types)]
#![warn(missing_docs)]
#![warn(missing_copy_implementations)]
use std::ffi::CStr;
use std::os::raw::c_char;
use std::slice;
use resvg::tiny_skia;
use resvg::usvg;
/// @brief List of possible errors.
#[repr(C)]
#[derive(Copy, Clone)]
pub enum resvg_error {
/// Everything is ok.
OK = 0,
/// Only UTF-8 content are supported.
NOT_AN_UTF8_STR,
/// Failed to open the provided file.
FILE_OPEN_FAILED,
/// Compressed SVG must use the GZip algorithm.
MALFORMED_GZIP,
/// We do not allow SVG with more than 1_000_000 elements for security reasons.
ELEMENTS_LIMIT_REACHED,
/// SVG doesn't have a valid size.
///
/// Occurs when width and/or height are <= 0.
///
/// Also occurs if width, height and viewBox are not set.
INVALID_SIZE,
/// Failed to parse an SVG data.
PARSING_FAILED,
}
/// @brief A rectangle representation.
#[repr(C)]
#[allow(missing_docs)]
#[derive(Copy, Clone)]
pub struct resvg_rect {
pub x: f32,
pub y: f32,
pub width: f32,
pub height: f32,
}
/// @brief A size representation.
#[repr(C)]
#[allow(missing_docs)]
#[derive(Copy, Clone)]
pub struct resvg_size {
pub width: f32,
pub height: f32,
}
/// @brief A 2D transform representation.
#[repr(C)]
#[allow(missing_docs)]
#[derive(Copy, Clone)]
pub struct resvg_transform {
pub a: f32,
pub b: f32,
pub c: f32,
pub d: f32,
pub e: f32,
pub f: f32,
}
impl resvg_transform {
#[inline]
fn to_tiny_skia(&self) -> tiny_skia::Transform {
tiny_skia::Transform::from_row(self.a, self.b, self.c, self.d, self.e, self.f)
}
}
/// @brief Creates an identity transform.
#[no_mangle]
pub extern "C" fn resvg_transform_identity() -> resvg_transform {
resvg_transform {
a: 1.0,
b: 0.0,
c: 0.0,
d: 1.0,
e: 0.0,
f: 0.0,
}
}
/// @brief Initializes the library log.
///
/// Use it if you want to see any warnings.
///
/// Must be called only once.
///
/// All warnings will be printed to the `stderr`.
#[no_mangle]
pub extern "C" fn resvg_init_log() {
if let Ok(()) = log::set_logger(&LOGGER) {
log::set_max_level(log::LevelFilter::Warn);
}
}
/// @brief An SVG to #resvg_render_tree conversion options.
///
/// Also, contains a fonts database used during text to path conversion.
/// The database is empty by default.
pub struct resvg_options {
options: usvg::Options<'static>,
}
/// @brief Creates a new #resvg_options object.
///
/// Should be destroyed via #resvg_options_destroy.
#[no_mangle]
pub extern "C" fn resvg_options_create() -> *mut resvg_options {
Box::into_raw(Box::new(resvg_options {
options: usvg::Options::default(),
}))
}
#[inline]
fn cast_opt(opt: *mut resvg_options) -> &'static mut usvg::Options<'static> {
unsafe {
assert!(!opt.is_null());
&mut (*opt).options
}
}
/// @brief Sets a directory that will be used during relative paths resolving.
///
/// Expected to be the same as the directory that contains the SVG file,
/// but can be set to any.
///
/// Must be UTF-8. Can be set to NULL.
///
/// Default: NULL
#[no_mangle]
pub extern "C" fn resvg_options_set_resources_dir(opt: *mut resvg_options, path: *const c_char) {
if path.is_null() {
cast_opt(opt).resources_dir = None;
} else {
cast_opt(opt).resources_dir = Some(cstr_to_str(path).unwrap().into());
}
}
/// @brief Sets the target DPI.
///
/// Impact units conversion.
///
/// Default: 96
#[no_mangle]
pub extern "C" fn resvg_options_set_dpi(opt: *mut resvg_options, dpi: f32) {
cast_opt(opt).dpi = dpi as f32;
}
/// @brief Sets the default font family.
///
/// Will be used when no `font-family` attribute is set in the SVG.
///
/// Must be UTF-8. NULL is not allowed.
///
/// Default: Times New Roman
#[no_mangle]
pub extern "C" fn resvg_options_set_font_family(opt: *mut resvg_options, family: *const c_char) {
cast_opt(opt).font_family = cstr_to_str(family).unwrap().to_string();
}
/// @brief Sets the default font size.
///
/// Will be used when no `font-size` attribute is set in the SVG.
///
/// Default: 12
#[no_mangle]
pub extern "C" fn resvg_options_set_font_size(opt: *mut resvg_options, size: f32) {
cast_opt(opt).font_size = size;
}
/// @brief Sets the `serif` font family.
///
/// Must be UTF-8. NULL is not allowed.
///
/// Has no effect when the `text` feature is not enabled.
///
/// Default: Times New Roman
#[no_mangle]
#[allow(unused_variables)]
pub extern "C" fn resvg_options_set_serif_family(opt: *mut resvg_options, family: *const c_char) {
#[cfg(feature = "text")]
{
cast_opt(opt)
.fontdb_mut()
.set_serif_family(cstr_to_str(family).unwrap().to_string());
}
}
/// @brief Sets the `sans-serif` font family.
///
/// Must be UTF-8. NULL is not allowed.
///
/// Has no effect when the `text` feature is not enabled.
///
/// Default: Arial
#[no_mangle]
#[allow(unused_variables)]
pub extern "C" fn resvg_options_set_sans_serif_family(
opt: *mut resvg_options,
family: *const c_char,
) {
#[cfg(feature = "text")]
{
cast_opt(opt)
.fontdb_mut()
.set_sans_serif_family(cstr_to_str(family).unwrap().to_string());
}
}
/// @brief Sets the `cursive` font family.
///
/// Must be UTF-8. NULL is not allowed.
///
/// Has no effect when the `text` feature is not enabled.
///
/// Default: Comic Sans MS
#[no_mangle]
#[allow(unused_variables)]
pub extern "C" fn resvg_options_set_cursive_family(opt: *mut resvg_options, family: *const c_char) {
#[cfg(feature = "text")]
{
cast_opt(opt)
.fontdb_mut()
.set_cursive_family(cstr_to_str(family).unwrap().to_string());
}
}
/// @brief Sets the `fantasy` font family.
///
/// Must be UTF-8. NULL is not allowed.
///
/// Has no effect when the `text` feature is not enabled.
///
/// Default: Papyrus on macOS, Impact on other OS'es
#[no_mangle]
#[allow(unused_variables)]
pub extern "C" fn resvg_options_set_fantasy_family(opt: *mut resvg_options, family: *const c_char) {
#[cfg(feature = "text")]
{
cast_opt(opt)
.fontdb_mut()
.set_fantasy_family(cstr_to_str(family).unwrap().to_string());
}
}
/// @brief Sets the `monospace` font family.
///
/// Must be UTF-8. NULL is not allowed.
///
/// Has no effect when the `text` feature is not enabled.
///
/// Default: Courier New
#[no_mangle]
#[allow(unused_variables)]
pub extern "C" fn resvg_options_set_monospace_family(
opt: *mut resvg_options,
family: *const c_char,
) {
#[cfg(feature = "text")]
{
cast_opt(opt)
.fontdb_mut()
.set_monospace_family(cstr_to_str(family).unwrap().to_string());
}
}
/// @brief Sets a comma-separated list of languages.
///
/// Will be used to resolve a `systemLanguage` conditional attribute.
///
/// Example: en,en-US.
///
/// Must be UTF-8. Can be NULL.
///
/// Default: en
#[no_mangle]
pub extern "C" fn resvg_options_set_languages(opt: *mut resvg_options, languages: *const c_char) {
if languages.is_null() {
cast_opt(opt).languages = Vec::new();
return;
}
let languages_str = match cstr_to_str(languages) {
Some(v) => v,
None => return,
};
let mut languages = Vec::new();
for lang in languages_str.split(',') {
languages.push(lang.trim().to_string());
}
cast_opt(opt).languages = languages;
}
/// @brief A shape rendering method.
#[repr(C)]
#[allow(missing_docs)]
#[derive(Copy, Clone)]
pub enum resvg_shape_rendering {
OPTIMIZE_SPEED,
CRISP_EDGES,
GEOMETRIC_PRECISION,
}
/// @brief Sets the default shape rendering method.
///
/// Will be used when an SVG element's `shape-rendering` property is set to `auto`.
///
/// Default: `RESVG_SHAPE_RENDERING_GEOMETRIC_PRECISION`
#[no_mangle]
pub extern "C" fn resvg_options_set_shape_rendering_mode(
opt: *mut resvg_options,
mode: resvg_shape_rendering,
) {
cast_opt(opt).shape_rendering = match mode as i32 {
0 => usvg::ShapeRendering::OptimizeSpeed,
1 => usvg::ShapeRendering::CrispEdges,
2 => usvg::ShapeRendering::GeometricPrecision,
_ => return,
}
}
/// @brief A text rendering method.
#[repr(C)]
#[allow(missing_docs)]
#[derive(Copy, Clone)]
pub enum resvg_text_rendering {
OPTIMIZE_SPEED,
OPTIMIZE_LEGIBILITY,
GEOMETRIC_PRECISION,
}
/// @brief Sets the default text rendering method.
///
/// Will be used when an SVG element's `text-rendering` property is set to `auto`.
///
/// Default: `RESVG_TEXT_RENDERING_OPTIMIZE_LEGIBILITY`
#[no_mangle]
pub extern "C" fn resvg_options_set_text_rendering_mode(
opt: *mut resvg_options,
mode: resvg_text_rendering,
) {
cast_opt(opt).text_rendering = match mode as i32 {
0 => usvg::TextRendering::OptimizeSpeed,
1 => usvg::TextRendering::OptimizeLegibility,
2 => usvg::TextRendering::GeometricPrecision,
_ => return,
}
}
/// @brief A image rendering method.
#[repr(C)]
#[allow(missing_docs)]
#[derive(Copy, Clone)]
pub enum resvg_image_rendering {
OPTIMIZE_QUALITY,
OPTIMIZE_SPEED,
}
/// @brief Sets the default image rendering method.
///
/// Will be used when an SVG element's `image-rendering` property is set to `auto`.
///
/// Default: `RESVG_IMAGE_RENDERING_OPTIMIZE_QUALITY`
#[no_mangle]
pub extern "C" fn resvg_options_set_image_rendering_mode(
opt: *mut resvg_options,
mode: resvg_image_rendering,
) {
cast_opt(opt).image_rendering = match mode as i32 {
0 => usvg::ImageRendering::OptimizeQuality,
1 => usvg::ImageRendering::OptimizeSpeed,
_ => return,
}
}
/// @brief Loads a font data into the internal fonts database.
///
/// Prints a warning into the log when the data is not a valid TrueType font.
///
/// Has no effect when the `text` feature is not enabled.
#[no_mangle]
#[allow(unused_variables)]
pub extern "C" fn resvg_options_load_font_data(
opt: *mut resvg_options,
data: *const c_char,
len: usize,
) {
#[cfg(feature = "text")]
{
let data = unsafe { slice::from_raw_parts(data as *const u8, len) };
cast_opt(opt).fontdb_mut().load_font_data(data.to_vec())
}
}
/// @brief Loads a font file into the internal fonts database.
///
/// Prints a warning into the log when the data is not a valid TrueType font.
///
/// Has no effect when the `text` feature is not enabled.
///
/// @return #resvg_error with RESVG_OK, RESVG_ERROR_NOT_AN_UTF8_STR or RESVG_ERROR_FILE_OPEN_FAILED
#[no_mangle]
#[allow(unused_variables)]
pub extern "C" fn resvg_options_load_font_file(
opt: *mut resvg_options,
file_path: *const c_char,
) -> i32 {
#[cfg(feature = "text")]
{
let file_path = match cstr_to_str(file_path) {
Some(v) => v,
None => return resvg_error::NOT_AN_UTF8_STR as i32,
};
if cast_opt(opt).fontdb_mut().load_font_file(file_path).is_ok() {
resvg_error::OK as i32
} else {
resvg_error::FILE_OPEN_FAILED as i32
}
}
#[cfg(not(feature = "text"))]
{
resvg_error::OK as i32
}
}
/// @brief Loads system fonts into the internal fonts database.
///
/// This method is very IO intensive.
///
/// This method should be executed only once per #resvg_options.
///
/// The system scanning is not perfect, so some fonts may be omitted.
/// Please send a bug report in this case.
///
/// Prints warnings into the log.
///
/// Has no effect when the `text` feature is not enabled.
#[no_mangle]
#[allow(unused_variables)]
pub extern "C" fn resvg_options_load_system_fonts(opt: *mut resvg_options) {
#[cfg(feature = "text")]
{
cast_opt(opt).fontdb_mut().load_system_fonts();
}
}
/// @brief Destroys the #resvg_options.
#[no_mangle]
pub extern "C" fn resvg_options_destroy(opt: *mut resvg_options) {
unsafe {
assert!(!opt.is_null());
let _ = Box::from_raw(opt);
};
}
// TODO: use resvg::Tree
/// @brief An opaque pointer to the rendering tree.
pub struct resvg_render_tree(pub usvg::Tree);
/// @brief Creates #resvg_render_tree from file.
///
/// .svg and .svgz files are supported.
///
/// See #resvg_is_image_empty for details.
///
/// @param file_path UTF-8 file path.
/// @param opt Rendering options. Must not be NULL.
/// @param tree Parsed render tree. Should be destroyed via #resvg_tree_destroy.
/// @return #resvg_error
#[no_mangle]
pub extern "C" fn resvg_parse_tree_from_file(
file_path: *const c_char,
opt: *const resvg_options,
tree: *mut *mut resvg_render_tree,
) -> i32 {
let file_path = match cstr_to_str(file_path) {
Some(v) => v,
None => return resvg_error::NOT_AN_UTF8_STR as i32,
};
let raw_opt = unsafe {
assert!(!opt.is_null());
&*opt
};
let file_data = match std::fs::read(file_path) {
Ok(tree) => tree,
Err(_) => return resvg_error::FILE_OPEN_FAILED as i32,
};
let utree = usvg::Tree::from_data(&file_data, &raw_opt.options);
let utree = match utree {
Ok(tree) => tree,
Err(e) => return convert_error(e) as i32,
};
let tree_box = Box::new(resvg_render_tree(utree));
unsafe {
*tree = Box::into_raw(tree_box);
}
resvg_error::OK as i32
}
/// @brief Creates #resvg_render_tree from data.
///
/// See #resvg_is_image_empty for details.
///
/// @param data SVG data. Can contain SVG string or gzip compressed data. Must not be NULL.
/// @param len Data length.
/// @param opt Rendering options. Must not be NULL.
/// @param tree Parsed render tree. Should be destroyed via #resvg_tree_destroy.
/// @return #resvg_error
#[no_mangle]
pub extern "C" fn resvg_parse_tree_from_data(
data: *const c_char,
len: usize,
opt: *const resvg_options,
tree: *mut *mut resvg_render_tree,
) -> i32 {
let data = unsafe { slice::from_raw_parts(data as *const u8, len) };
let raw_opt = unsafe {
assert!(!opt.is_null());
&*opt
};
let utree = usvg::Tree::from_data(data, &raw_opt.options);
let utree = match utree {
Ok(tree) => tree,
Err(e) => return convert_error(e) as i32,
};
let tree_box = Box::new(resvg_render_tree(utree));
unsafe {
*tree = Box::into_raw(tree_box);
}
resvg_error::OK as i32
}
/// @brief Checks that tree has any nodes.
///
/// @param tree Render tree.
/// @return Returns `true` if tree has no nodes.
#[no_mangle]
pub extern "C" fn resvg_is_image_empty(tree: *const resvg_render_tree) -> bool {
let tree = unsafe {
assert!(!tree.is_null());
&*tree
};
!tree.0.root().has_children()
}
/// @brief Returns an image size.
///
/// The size of an image that is required to render this SVG.
///
/// Note that elements outside the viewbox will be clipped. This is by design.
/// If you want to render the whole SVG content, use #resvg_get_image_bbox instead.
///
/// @param tree Render tree.
/// @return Image size.
#[no_mangle]
pub extern "C" fn resvg_get_image_size(tree: *const resvg_render_tree) -> resvg_size {
let tree = unsafe {
assert!(!tree.is_null());
&*tree
};
let size = tree.0.size();
resvg_size {
width: size.width(),
height: size.height(),
}
}
/// @brief Returns an object bounding box.
///
/// This bounding box does not include objects stroke and filter regions.
/// This is what SVG calls "absolute object bonding box".
///
/// If you're looking for a "complete" bounding box see #resvg_get_image_bbox
///
/// @param tree Render tree.
/// @param bbox Image's object bounding box.
/// @return `false` if an image has no elements.
#[no_mangle]
pub extern "C" fn resvg_get_object_bbox(
tree: *const resvg_render_tree,
bbox: *mut resvg_rect,
) -> bool {
let tree = unsafe {
assert!(!tree.is_null());
&*tree
};
if let Some(r) = tree.0.root().abs_bounding_box().to_non_zero_rect() {
unsafe {
*bbox = resvg_rect {
x: r.x(),
y: r.y(),
width: r.width(),
height: r.height(),
}
}
true
} else {
false
}
}
/// @brief Returns an image bounding box.
///
/// This bounding box contains the maximum SVG dimensions.
/// It's size can be bigger or smaller than #resvg_get_image_size
/// Use it when you want to avoid clipping of elements that are outside the SVG viewbox.
///
/// @param tree Render tree.
/// @param bbox Image's bounding box.
/// @return `false` if an image has no elements.
#[no_mangle]
pub extern "C" fn resvg_get_image_bbox(
tree: *const resvg_render_tree,
bbox: *mut resvg_rect,
) -> bool {
let tree = unsafe {
assert!(!tree.is_null());
&*tree
};
// `abs_layer_bounding_box` returns 0x0x1x1 for empty groups, so we need additional checks.
if tree.0.root().has_children() || !tree.0.root().filters().is_empty() {
let r = tree.0.root().abs_layer_bounding_box();
unsafe {
*bbox = resvg_rect {
x: r.x(),
y: r.y(),
width: r.width(),
height: r.height(),
}
}
true
} else {
false
}
}
/// @brief Returns `true` if a renderable node with such an ID exists.
///
/// @param tree Render tree.
/// @param id Node's ID. UTF-8 string. Must not be NULL.
/// @return `true` if a node exists.
/// @return `false` if a node doesn't exist or ID isn't a UTF-8 string.
/// @return `false` if a node exists, but not renderable.
#[no_mangle]
pub extern "C" fn resvg_node_exists(tree: *const resvg_render_tree, id: *const c_char) -> bool {
let id = match cstr_to_str(id) {
Some(v) => v,
None => {
log::warn!("Provided ID is no an UTF-8 string.");
return false;
}
};
let tree = unsafe {
assert!(!tree.is_null());
&*tree
};
tree.0.node_by_id(id).is_some()
}
/// @brief Returns node's transform by ID.
///
/// @param tree Render tree.
/// @param id Node's ID. UTF-8 string. Must not be NULL.
/// @param transform Node's transform.
/// @return `true` if a node exists.
/// @return `false` if a node doesn't exist or ID isn't a UTF-8 string.
/// @return `false` if a node exists, but not renderable.
#[no_mangle]
pub extern "C" fn resvg_get_node_transform(
tree: *const resvg_render_tree,
id: *const c_char,
transform: *mut resvg_transform,
) -> bool {
let id = match cstr_to_str(id) {
Some(v) => v,
None => {
log::warn!("Provided ID is no an UTF-8 string.");
return false;
}
};
let tree = unsafe {
assert!(!tree.is_null());
&*tree
};
if let Some(node) = tree.0.node_by_id(id) {
let abs_ts = node.abs_transform();
unsafe {
*transform = resvg_transform {
a: abs_ts.sx,
b: abs_ts.ky,
c: abs_ts.kx,
d: abs_ts.sy,
e: abs_ts.tx,
f: abs_ts.ty,
}
}
return true;
}
false
}
/// @brief Returns node's bounding box in canvas coordinates by ID.
///
/// @param tree Render tree.
/// @param id Node's ID. Must not be NULL.
/// @param bbox Node's bounding box.
/// @return `false` if a node with such an ID does not exist
/// @return `false` if ID isn't a UTF-8 string.
/// @return `false` if ID is an empty string
#[no_mangle]
pub extern "C" fn resvg_get_node_bbox(
tree: *const resvg_render_tree,
id: *const c_char,
bbox: *mut resvg_rect,
) -> bool {
get_node_bbox(tree, id, bbox, &|node| node.abs_bounding_box())
}
/// @brief Returns node's bounding box, including stroke, in canvas coordinates by ID.
///
/// @param tree Render tree.
/// @param id Node's ID. Must not be NULL.
/// @param bbox Node's bounding box.
/// @return `false` if a node with such an ID does not exist
/// @return `false` if ID isn't a UTF-8 string.
/// @return `false` if ID is an empty string
#[no_mangle]
pub extern "C" fn resvg_get_node_stroke_bbox(
tree: *const resvg_render_tree,
id: *const c_char,
bbox: *mut resvg_rect,
) -> bool {
get_node_bbox(tree, id, bbox, &|node| node.abs_stroke_bounding_box())
}
fn get_node_bbox(
tree: *const resvg_render_tree,
id: *const c_char,
bbox: *mut resvg_rect,
f: &dyn Fn(&usvg::Node) -> usvg::Rect,
) -> bool {
let id = match cstr_to_str(id) {
Some(v) => v,
None => {
log::warn!("Provided ID is no an UTF-8 string.");
return false;
}
};
if id.is_empty() {
log::warn!("Node ID must not be empty.");
return false;
}
let tree = unsafe {
assert!(!tree.is_null());
&*tree
};
match tree.0.node_by_id(id) {
Some(node) => {
let r = f(node);
unsafe {
*bbox = resvg_rect {
x: r.x(),
y: r.y(),
width: r.width(),
height: r.height(),
}
}
true
}
None => {
log::warn!("No node with '{}' ID is in the tree.", id);
false
}
}
}
/// @brief Destroys the #resvg_render_tree.
#[no_mangle]
pub extern "C" fn resvg_tree_destroy(tree: *mut resvg_render_tree) {
unsafe {
assert!(!tree.is_null());
let _ = Box::from_raw(tree);
};
}
fn cstr_to_str(text: *const c_char) -> Option<&'static str> {
let text = unsafe {
assert!(!text.is_null());
CStr::from_ptr(text)
};
text.to_str().ok()
}
fn convert_error(e: usvg::Error) -> resvg_error {
match e {
usvg::Error::NotAnUtf8Str => resvg_error::NOT_AN_UTF8_STR,
usvg::Error::MalformedGZip => resvg_error::MALFORMED_GZIP,
usvg::Error::ElementsLimitReached => resvg_error::ELEMENTS_LIMIT_REACHED,
usvg::Error::InvalidSize => resvg_error::INVALID_SIZE,
usvg::Error::ParsingFailed(_) => resvg_error::PARSING_FAILED,
}
}
/// @brief Renders the #resvg_render_tree onto the pixmap.
///
/// @param tree A render tree.
/// @param transform A root SVG transform. Can be used to position SVG inside the `pixmap`.
/// @param width Pixmap width.
/// @param height Pixmap height.
/// @param pixmap Pixmap data. Should have width*height*4 size and contain
/// premultiplied RGBA8888 pixels.
#[no_mangle]
pub extern "C" fn resvg_render(
tree: *const resvg_render_tree,
transform: resvg_transform,
width: u32,
height: u32,
pixmap: *mut c_char,
) {
let tree = unsafe {
assert!(!tree.is_null());
&*tree
};
let pixmap_len = width as usize * height as usize * tiny_skia::BYTES_PER_PIXEL;
let pixmap: &mut [u8] =
unsafe { std::slice::from_raw_parts_mut(pixmap as *mut u8, pixmap_len) };
let mut pixmap = tiny_skia::PixmapMut::from_bytes(pixmap, width, height).unwrap();
resvg::render(&tree.0, transform.to_tiny_skia(), &mut pixmap)
}
/// @brief Renders a Node by ID onto the image.
///
/// @param tree A render tree.
/// @param id Node's ID. Must not be NULL.
/// @param transform A root SVG transform. Can be used to position SVG inside the `pixmap`.
/// @param width Pixmap width.
/// @param height Pixmap height.
/// @param pixmap Pixmap data. Should have width*height*4 size and contain
/// premultiplied RGBA8888 pixels.
/// @return `false` when `id` is not a non-empty UTF-8 string.
/// @return `false` when the selected `id` is not present.
/// @return `false` when an element has a zero bbox.
#[no_mangle]
pub extern "C" fn resvg_render_node(
tree: *const resvg_render_tree,
id: *const c_char,
transform: resvg_transform,
width: u32,
height: u32,
pixmap: *mut c_char,
) -> bool {
let tree = unsafe {
assert!(!tree.is_null());
&*tree
};
let id = match cstr_to_str(id) {
Some(v) => v,
None => return false,
};
if id.is_empty() {
log::warn!("Node with an empty ID cannot be rendered.");
return false;
}
if let Some(node) = tree.0.node_by_id(id) {
let pixmap_len = width as usize * height as usize * tiny_skia::BYTES_PER_PIXEL;
let pixmap: &mut [u8] =
unsafe { std::slice::from_raw_parts_mut(pixmap as *mut u8, pixmap_len) };
let mut pixmap = tiny_skia::PixmapMut::from_bytes(pixmap, width, height).unwrap();
resvg::render_node(node, transform.to_tiny_skia(), &mut pixmap).is_some()
} else {
log::warn!("A node with '{}' ID wasn't found.", id);
false
}
}
/// A simple stderr logger.
static LOGGER: SimpleLogger = SimpleLogger;
struct SimpleLogger;
impl log::Log for SimpleLogger {
fn enabled(&self, metadata: &log::Metadata) -> bool {
metadata.level() <= log::LevelFilter::Warn
}
fn log(&self, record: &log::Record) {
if self.enabled(record.metadata()) {
let target = if record.target().len() > 0 {
record.target()
} else {
record.module_path().unwrap_or_default()
};
let line = record.line().unwrap_or(0);
let args = record.args();
match record.level() {
log::Level::Error => eprintln!("Error (in {}:{}): {}", target, line, args),
log::Level::Warn => eprintln!("Warning (in {}:{}): {}", target, line, args),
log::Level::Info => eprintln!("Info (in {}:{}): {}", target, line, args),
log::Level::Debug => eprintln!("Debug (in {}:{}): {}", target, line, args),
log::Level::Trace => eprintln!("Trace (in {}:{}): {}", target, line, args),
}
}
}
fn flush(&self) {}
}
resvg-0.44.0/crates/c-api/resvg.h 0000664 0000000 0000000 00000033005 14675720665 0016521 0 ustar 00root root 0000000 0000000 /*
* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/.
*/
/**
* @file resvg.h
*
* resvg C API
*/
#ifndef RESVG_H
#define RESVG_H
#include
#include
#define RESVG_MAJOR_VERSION 0
#define RESVG_MINOR_VERSION 44
#define RESVG_PATCH_VERSION 0
#define RESVG_VERSION "0.44.0"
/**
* @brief List of possible errors.
*/
typedef enum {
/**
* Everything is ok.
*/
RESVG_OK = 0,
/**
* Only UTF-8 content are supported.
*/
RESVG_ERROR_NOT_AN_UTF8_STR,
/**
* Failed to open the provided file.
*/
RESVG_ERROR_FILE_OPEN_FAILED,
/**
* Compressed SVG must use the GZip algorithm.
*/
RESVG_ERROR_MALFORMED_GZIP,
/**
* We do not allow SVG with more than 1_000_000 elements for security reasons.
*/
RESVG_ERROR_ELEMENTS_LIMIT_REACHED,
/**
* SVG doesn't have a valid size.
*
* Occurs when width and/or height are <= 0.
*
* Also occurs if width, height and viewBox are not set.
*/
RESVG_ERROR_INVALID_SIZE,
/**
* Failed to parse an SVG data.
*/
RESVG_ERROR_PARSING_FAILED,
} resvg_error;
/**
* @brief A image rendering method.
*/
typedef enum {
RESVG_IMAGE_RENDERING_OPTIMIZE_QUALITY,
RESVG_IMAGE_RENDERING_OPTIMIZE_SPEED,
} resvg_image_rendering;
/**
* @brief A shape rendering method.
*/
typedef enum {
RESVG_SHAPE_RENDERING_OPTIMIZE_SPEED,
RESVG_SHAPE_RENDERING_CRISP_EDGES,
RESVG_SHAPE_RENDERING_GEOMETRIC_PRECISION,
} resvg_shape_rendering;
/**
* @brief A text rendering method.
*/
typedef enum {
RESVG_TEXT_RENDERING_OPTIMIZE_SPEED,
RESVG_TEXT_RENDERING_OPTIMIZE_LEGIBILITY,
RESVG_TEXT_RENDERING_GEOMETRIC_PRECISION,
} resvg_text_rendering;
/**
* @brief An SVG to #resvg_render_tree conversion options.
*
* Also, contains a fonts database used during text to path conversion.
* The database is empty by default.
*/
typedef struct resvg_options resvg_options;
/**
* @brief An opaque pointer to the rendering tree.
*/
typedef struct resvg_render_tree resvg_render_tree;
/**
* @brief A 2D transform representation.
*/
typedef struct {
float a;
float b;
float c;
float d;
float e;
float f;
} resvg_transform;
/**
* @brief A size representation.
*/
typedef struct {
float width;
float height;
} resvg_size;
/**
* @brief A rectangle representation.
*/
typedef struct {
float x;
float y;
float width;
float height;
} resvg_rect;
#ifdef __cplusplus
extern "C" {
#endif // __cplusplus
/**
* @brief Creates an identity transform.
*/
resvg_transform resvg_transform_identity(void);
/**
* @brief Initializes the library log.
*
* Use it if you want to see any warnings.
*
* Must be called only once.
*
* All warnings will be printed to the `stderr`.
*/
void resvg_init_log(void);
/**
* @brief Creates a new #resvg_options object.
*
* Should be destroyed via #resvg_options_destroy.
*/
resvg_options *resvg_options_create(void);
/**
* @brief Sets a directory that will be used during relative paths resolving.
*
* Expected to be the same as the directory that contains the SVG file,
* but can be set to any.
*
* Must be UTF-8. Can be set to NULL.
*
* Default: NULL
*/
void resvg_options_set_resources_dir(resvg_options *opt, const char *path);
/**
* @brief Sets the target DPI.
*
* Impact units conversion.
*
* Default: 96
*/
void resvg_options_set_dpi(resvg_options *opt, float dpi);
/**
* @brief Sets the default font family.
*
* Will be used when no `font-family` attribute is set in the SVG.
*
* Must be UTF-8. NULL is not allowed.
*
* Default: Times New Roman
*/
void resvg_options_set_font_family(resvg_options *opt, const char *family);
/**
* @brief Sets the default font size.
*
* Will be used when no `font-size` attribute is set in the SVG.
*
* Default: 12
*/
void resvg_options_set_font_size(resvg_options *opt, float size);
/**
* @brief Sets the `serif` font family.
*
* Must be UTF-8. NULL is not allowed.
*
* Has no effect when the `text` feature is not enabled.
*
* Default: Times New Roman
*/
void resvg_options_set_serif_family(resvg_options *opt, const char *family);
/**
* @brief Sets the `sans-serif` font family.
*
* Must be UTF-8. NULL is not allowed.
*
* Has no effect when the `text` feature is not enabled.
*
* Default: Arial
*/
void resvg_options_set_sans_serif_family(resvg_options *opt, const char *family);
/**
* @brief Sets the `cursive` font family.
*
* Must be UTF-8. NULL is not allowed.
*
* Has no effect when the `text` feature is not enabled.
*
* Default: Comic Sans MS
*/
void resvg_options_set_cursive_family(resvg_options *opt, const char *family);
/**
* @brief Sets the `fantasy` font family.
*
* Must be UTF-8. NULL is not allowed.
*
* Has no effect when the `text` feature is not enabled.
*
* Default: Papyrus on macOS, Impact on other OS'es
*/
void resvg_options_set_fantasy_family(resvg_options *opt, const char *family);
/**
* @brief Sets the `monospace` font family.
*
* Must be UTF-8. NULL is not allowed.
*
* Has no effect when the `text` feature is not enabled.
*
* Default: Courier New
*/
void resvg_options_set_monospace_family(resvg_options *opt, const char *family);
/**
* @brief Sets a comma-separated list of languages.
*
* Will be used to resolve a `systemLanguage` conditional attribute.
*
* Example: en,en-US.
*
* Must be UTF-8. Can be NULL.
*
* Default: en
*/
void resvg_options_set_languages(resvg_options *opt, const char *languages);
/**
* @brief Sets the default shape rendering method.
*
* Will be used when an SVG element's `shape-rendering` property is set to `auto`.
*
* Default: `RESVG_SHAPE_RENDERING_GEOMETRIC_PRECISION`
*/
void resvg_options_set_shape_rendering_mode(resvg_options *opt, resvg_shape_rendering mode);
/**
* @brief Sets the default text rendering method.
*
* Will be used when an SVG element's `text-rendering` property is set to `auto`.
*
* Default: `RESVG_TEXT_RENDERING_OPTIMIZE_LEGIBILITY`
*/
void resvg_options_set_text_rendering_mode(resvg_options *opt, resvg_text_rendering mode);
/**
* @brief Sets the default image rendering method.
*
* Will be used when an SVG element's `image-rendering` property is set to `auto`.
*
* Default: `RESVG_IMAGE_RENDERING_OPTIMIZE_QUALITY`
*/
void resvg_options_set_image_rendering_mode(resvg_options *opt, resvg_image_rendering mode);
/**
* @brief Loads a font data into the internal fonts database.
*
* Prints a warning into the log when the data is not a valid TrueType font.
*
* Has no effect when the `text` feature is not enabled.
*/
void resvg_options_load_font_data(resvg_options *opt, const char *data, uintptr_t len);
/**
* @brief Loads a font file into the internal fonts database.
*
* Prints a warning into the log when the data is not a valid TrueType font.
*
* Has no effect when the `text` feature is not enabled.
*
* @return #resvg_error with RESVG_OK, RESVG_ERROR_NOT_AN_UTF8_STR or RESVG_ERROR_FILE_OPEN_FAILED
*/
int32_t resvg_options_load_font_file(resvg_options *opt, const char *file_path);
/**
* @brief Loads system fonts into the internal fonts database.
*
* This method is very IO intensive.
*
* This method should be executed only once per #resvg_options.
*
* The system scanning is not perfect, so some fonts may be omitted.
* Please send a bug report in this case.
*
* Prints warnings into the log.
*
* Has no effect when the `text` feature is not enabled.
*/
void resvg_options_load_system_fonts(resvg_options *opt);
/**
* @brief Destroys the #resvg_options.
*/
void resvg_options_destroy(resvg_options *opt);
/**
* @brief Creates #resvg_render_tree from file.
*
* .svg and .svgz files are supported.
*
* See #resvg_is_image_empty for details.
*
* @param file_path UTF-8 file path.
* @param opt Rendering options. Must not be NULL.
* @param tree Parsed render tree. Should be destroyed via #resvg_tree_destroy.
* @return #resvg_error
*/
int32_t resvg_parse_tree_from_file(const char *file_path,
const resvg_options *opt,
resvg_render_tree **tree);
/**
* @brief Creates #resvg_render_tree from data.
*
* See #resvg_is_image_empty for details.
*
* @param data SVG data. Can contain SVG string or gzip compressed data. Must not be NULL.
* @param len Data length.
* @param opt Rendering options. Must not be NULL.
* @param tree Parsed render tree. Should be destroyed via #resvg_tree_destroy.
* @return #resvg_error
*/
int32_t resvg_parse_tree_from_data(const char *data,
uintptr_t len,
const resvg_options *opt,
resvg_render_tree **tree);
/**
* @brief Checks that tree has any nodes.
*
* @param tree Render tree.
* @return Returns `true` if tree has no nodes.
*/
bool resvg_is_image_empty(const resvg_render_tree *tree);
/**
* @brief Returns an image size.
*
* The size of an image that is required to render this SVG.
*
* Note that elements outside the viewbox will be clipped. This is by design.
* If you want to render the whole SVG content, use #resvg_get_image_bbox instead.
*
* @param tree Render tree.
* @return Image size.
*/
resvg_size resvg_get_image_size(const resvg_render_tree *tree);
/**
* @brief Returns an object bounding box.
*
* This bounding box does not include objects stroke and filter regions.
* This is what SVG calls "absolute object bonding box".
*
* If you're looking for a "complete" bounding box see #resvg_get_image_bbox
*
* @param tree Render tree.
* @param bbox Image's object bounding box.
* @return `false` if an image has no elements.
*/
bool resvg_get_object_bbox(const resvg_render_tree *tree, resvg_rect *bbox);
/**
* @brief Returns an image bounding box.
*
* This bounding box contains the maximum SVG dimensions.
* It's size can be bigger or smaller than #resvg_get_image_size
* Use it when you want to avoid clipping of elements that are outside the SVG viewbox.
*
* @param tree Render tree.
* @param bbox Image's bounding box.
* @return `false` if an image has no elements.
*/
bool resvg_get_image_bbox(const resvg_render_tree *tree, resvg_rect *bbox);
/**
* @brief Returns `true` if a renderable node with such an ID exists.
*
* @param tree Render tree.
* @param id Node's ID. UTF-8 string. Must not be NULL.
* @return `true` if a node exists.
* @return `false` if a node doesn't exist or ID isn't a UTF-8 string.
* @return `false` if a node exists, but not renderable.
*/
bool resvg_node_exists(const resvg_render_tree *tree, const char *id);
/**
* @brief Returns node's transform by ID.
*
* @param tree Render tree.
* @param id Node's ID. UTF-8 string. Must not be NULL.
* @param transform Node's transform.
* @return `true` if a node exists.
* @return `false` if a node doesn't exist or ID isn't a UTF-8 string.
* @return `false` if a node exists, but not renderable.
*/
bool resvg_get_node_transform(const resvg_render_tree *tree,
const char *id,
resvg_transform *transform);
/**
* @brief Returns node's bounding box in canvas coordinates by ID.
*
* @param tree Render tree.
* @param id Node's ID. Must not be NULL.
* @param bbox Node's bounding box.
* @return `false` if a node with such an ID does not exist
* @return `false` if ID isn't a UTF-8 string.
* @return `false` if ID is an empty string
*/
bool resvg_get_node_bbox(const resvg_render_tree *tree, const char *id, resvg_rect *bbox);
/**
* @brief Returns node's bounding box, including stroke, in canvas coordinates by ID.
*
* @param tree Render tree.
* @param id Node's ID. Must not be NULL.
* @param bbox Node's bounding box.
* @return `false` if a node with such an ID does not exist
* @return `false` if ID isn't a UTF-8 string.
* @return `false` if ID is an empty string
*/
bool resvg_get_node_stroke_bbox(const resvg_render_tree *tree, const char *id, resvg_rect *bbox);
/**
* @brief Destroys the #resvg_render_tree.
*/
void resvg_tree_destroy(resvg_render_tree *tree);
/**
* @brief Renders the #resvg_render_tree onto the pixmap.
*
* @param tree A render tree.
* @param transform A root SVG transform. Can be used to position SVG inside the `pixmap`.
* @param width Pixmap width.
* @param height Pixmap height.
* @param pixmap Pixmap data. Should have width*height*4 size and contain
* premultiplied RGBA8888 pixels.
*/
void resvg_render(const resvg_render_tree *tree,
resvg_transform transform,
uint32_t width,
uint32_t height,
char *pixmap);
/**
* @brief Renders a Node by ID onto the image.
*
* @param tree A render tree.
* @param id Node's ID. Must not be NULL.
* @param transform A root SVG transform. Can be used to position SVG inside the `pixmap`.
* @param width Pixmap width.
* @param height Pixmap height.
* @param pixmap Pixmap data. Should have width*height*4 size and contain
* premultiplied RGBA8888 pixels.
* @return `false` when `id` is not a non-empty UTF-8 string.
* @return `false` when the selected `id` is not present.
* @return `false` when an element has a zero bbox.
*/
bool resvg_render_node(const resvg_render_tree *tree,
const char *id,
resvg_transform transform,
uint32_t width,
uint32_t height,
char *pixmap);
#ifdef __cplusplus
} // extern "C"
#endif // __cplusplus
#endif /* RESVG_H */
resvg-0.44.0/crates/resvg/ 0000775 0000000 0000000 00000000000 14675720665 0015356 5 ustar 00root root 0000000 0000000 resvg-0.44.0/crates/resvg/Cargo.toml 0000664 0000000 0000000 00000002542 14675720665 0017311 0 ustar 00root root 0000000 0000000 [package]
name = "resvg"
version = "0.44.0"
authors = ["Yevhenii Reizner "]
keywords = ["svg", "render", "raster"]
license = "MPL-2.0"
edition = "2021"
description = "An SVG rendering library."
repository = "https://github.com/RazrFalcon/resvg"
exclude = ["tests"]
workspace = "../.."
[[bin]]
name = "resvg"
required-features = ["text", "system-fonts", "memmap-fonts"]
[dependencies]
gif = { version = "0.13", optional = true }
image-webp = { version = "0.1.3", optional = true }
log = "0.4"
pico-args = { version = "0.5", features = ["eq-separator"] }
rgb = "0.8"
svgtypes = "0.15.2"
tiny-skia = "0.11.4"
usvg = { path = "../usvg", version = "0.44.0", default-features = false }
zune-jpeg = { version = "0.4", optional = true }
[dev-dependencies]
once_cell = "1.5"
png = "0.17"
[features]
default = ["text", "system-fonts", "memmap-fonts", "raster-images"]
# Enables SVG Text support.
# Adds around 400KiB to your binary.
text = ["usvg/text"]
# Enables system fonts loading (only for `text`).
system-fonts = ["usvg/system-fonts"]
# Enables font files memmaping for faster loading (only for `text`).
memmap-fonts = ["usvg/memmap-fonts"]
# Enables decoding and rendering of raster images.
# When disabled, `image` elements with SVG data will still be rendered.
# Adds around 200KiB to your binary.
raster-images = ["gif", "image-webp", "dep:zune-jpeg"]
resvg-0.44.0/crates/resvg/LICENSE.txt 0000664 0000000 0000000 00000040526 14675720665 0017210 0 ustar 00root root 0000000 0000000 Mozilla Public License Version 2.0
==================================
1. Definitions
--------------
1.1. "Contributor"
means each individual or legal entity that creates, contributes to
the creation of, or owns Covered Software.
1.2. "Contributor Version"
means the combination of the Contributions of others (if any) used
by a Contributor and that particular Contributor's Contribution.
1.3. "Contribution"
means Covered Software of a particular Contributor.
1.4. "Covered Software"
means Source Code Form to which the initial Contributor has attached
the notice in Exhibit A, the Executable Form of such Source Code
Form, and Modifications of such Source Code Form, in each case
including portions thereof.
1.5. "Incompatible With Secondary Licenses"
means
(a) that the initial Contributor has attached the notice described
in Exhibit B to the Covered Software; or
(b) that the Covered Software was made available under the terms of
version 1.1 or earlier of the License, but not also under the
terms of a Secondary License.
1.6. "Executable Form"
means any form of the work other than Source Code Form.
1.7. "Larger Work"
means a work that combines Covered Software with other material, in
a separate file or files, that is not Covered Software.
1.8. "License"
means this document.
1.9. "Licensable"
means having the right to grant, to the maximum extent possible,
whether at the time of the initial grant or subsequently, any and
all of the rights conveyed by this License.
1.10. "Modifications"
means any of the following:
(a) any file in Source Code Form that results from an addition to,
deletion from, or modification of the contents of Covered
Software; or
(b) any new file in Source Code Form that contains any Covered
Software.
1.11. "Patent Claims" of a Contributor
means any patent claim(s), including without limitation, method,
process, and apparatus claims, in any patent Licensable by such
Contributor that would be infringed, but for the grant of the
License, by the making, using, selling, offering for sale, having
made, import, or transfer of either its Contributions or its
Contributor Version.
1.12. "Secondary License"
means either the GNU General Public License, Version 2.0, the GNU
Lesser General Public License, Version 2.1, the GNU Affero General
Public License, Version 3.0, or any later versions of those
licenses.
1.13. "Source Code Form"
means the form of the work preferred for making modifications.
1.14. "You" (or "Your")
means an individual or a legal entity exercising rights under this
License. For legal entities, "You" includes any entity that
controls, is controlled by, or is under common control with You. For
purposes of this definition, "control" means (a) the power, direct
or indirect, to cause the direction or management of such entity,
whether by contract or otherwise, or (b) ownership of more than
fifty percent (50%) of the outstanding shares or beneficial
ownership of such entity.
2. License Grants and Conditions
--------------------------------
2.1. Grants
Each Contributor hereby grants You a world-wide, royalty-free,
non-exclusive license:
(a) under intellectual property rights (other than patent or trademark)
Licensable by such Contributor to use, reproduce, make available,
modify, display, perform, distribute, and otherwise exploit its
Contributions, either on an unmodified basis, with Modifications, or
as part of a Larger Work; and
(b) under Patent Claims of such Contributor to make, use, sell, offer
for sale, have made, import, and otherwise transfer either its
Contributions or its Contributor Version.
2.2. Effective Date
The licenses granted in Section 2.1 with respect to any Contribution
become effective for each Contribution on the date the Contributor first
distributes such Contribution.
2.3. Limitations on Grant Scope
The licenses granted in this Section 2 are the only rights granted under
this License. No additional rights or licenses will be implied from the
distribution or licensing of Covered Software under this License.
Notwithstanding Section 2.1(b) above, no patent license is granted by a
Contributor:
(a) for any code that a Contributor has removed from Covered Software;
or
(b) for infringements caused by: (i) Your and any other third party's
modifications of Covered Software, or (ii) the combination of its
Contributions with other software (except as part of its Contributor
Version); or
(c) under Patent Claims infringed by Covered Software in the absence of
its Contributions.
This License does not grant any rights in the trademarks, service marks,
or logos of any Contributor (except as may be necessary to comply with
the notice requirements in Section 3.4).
2.4. Subsequent Licenses
No Contributor makes additional grants as a result of Your choice to
distribute the Covered Software under a subsequent version of this
License (see Section 10.2) or under the terms of a Secondary License (if
permitted under the terms of Section 3.3).
2.5. Representation
Each Contributor represents that the Contributor believes its
Contributions are its original creation(s) or it has sufficient rights
to grant the rights to its Contributions conveyed by this License.
2.6. Fair Use
This License is not intended to limit any rights You have under
applicable copyright doctrines of fair use, fair dealing, or other
equivalents.
2.7. Conditions
Sections 3.1, 3.2, 3.3, and 3.4 are conditions of the licenses granted
in Section 2.1.
3. Responsibilities
-------------------
3.1. Distribution of Source Form
All distribution of Covered Software in Source Code Form, including any
Modifications that You create or to which You contribute, must be under
the terms of this License. You must inform recipients that the Source
Code Form of the Covered Software is governed by the terms of this
License, and how they can obtain a copy of this License. You may not
attempt to alter or restrict the recipients' rights in the Source Code
Form.
3.2. Distribution of Executable Form
If You distribute Covered Software in Executable Form then:
(a) such Covered Software must also be made available in Source Code
Form, as described in Section 3.1, and You must inform recipients of
the Executable Form how they can obtain a copy of such Source Code
Form by reasonable means in a timely manner, at a charge no more
than the cost of distribution to the recipient; and
(b) You may distribute such Executable Form under the terms of this
License, or sublicense it under different terms, provided that the
license for the Executable Form does not attempt to limit or alter
the recipients' rights in the Source Code Form under this License.
3.3. Distribution of a Larger Work
You may create and distribute a Larger Work under terms of Your choice,
provided that You also comply with the requirements of this License for
the Covered Software. If the Larger Work is a combination of Covered
Software with a work governed by one or more Secondary Licenses, and the
Covered Software is not Incompatible With Secondary Licenses, this
License permits You to additionally distribute such Covered Software
under the terms of such Secondary License(s), so that the recipient of
the Larger Work may, at their option, further distribute the Covered
Software under the terms of either this License or such Secondary
License(s).
3.4. Notices
You may not remove or alter the substance of any license notices
(including copyright notices, patent notices, disclaimers of warranty,
or limitations of liability) contained within the Source Code Form of
the Covered Software, except that You may alter any license notices to
the extent required to remedy known factual inaccuracies.
3.5. Application of Additional Terms
You may choose to offer, and to charge a fee for, warranty, support,
indemnity or liability obligations to one or more recipients of Covered
Software. However, You may do so only on Your own behalf, and not on
behalf of any Contributor. You must make it absolutely clear that any
such warranty, support, indemnity, or liability obligation is offered by
You alone, and You hereby agree to indemnify every Contributor for any
liability incurred by such Contributor as a result of warranty, support,
indemnity or liability terms You offer. You may include additional
disclaimers of warranty and limitations of liability specific to any
jurisdiction.
4. Inability to Comply Due to Statute or Regulation
---------------------------------------------------
If it is impossible for You to comply with any of the terms of this
License with respect to some or all of the Covered Software due to
statute, judicial order, or regulation then You must: (a) comply with
the terms of this License to the maximum extent possible; and (b)
describe the limitations and the code they affect. Such description must
be placed in a text file included with all distributions of the Covered
Software under this License. Except to the extent prohibited by statute
or regulation, such description must be sufficiently detailed for a
recipient of ordinary skill to be able to understand it.
5. Termination
--------------
5.1. The rights granted under this License will terminate automatically
if You fail to comply with any of its terms. However, if You become
compliant, then the rights granted under this License from a particular
Contributor are reinstated (a) provisionally, unless and until such
Contributor explicitly and finally terminates Your grants, and (b) on an
ongoing basis, if such Contributor fails to notify You of the
non-compliance by some reasonable means prior to 60 days after You have
come back into compliance. Moreover, Your grants from a particular
Contributor are reinstated on an ongoing basis if such Contributor
notifies You of the non-compliance by some reasonable means, this is the
first time You have received notice of non-compliance with this License
from such Contributor, and You become compliant prior to 30 days after
Your receipt of the notice.
5.2. If You initiate litigation against any entity by asserting a patent
infringement claim (excluding declaratory judgment actions,
counter-claims, and cross-claims) alleging that a Contributor Version
directly or indirectly infringes any patent, then the rights granted to
You by any and all Contributors for the Covered Software under Section
2.1 of this License shall terminate.
5.3. In the event of termination under Sections 5.1 or 5.2 above, all
end user license agreements (excluding distributors and resellers) which
have been validly granted by You or Your distributors under this License
prior to termination shall survive termination.
************************************************************************
* *
* 6. Disclaimer of Warranty *
* ------------------------- *
* *
* Covered Software is provided under this License on an "as is" *
* basis, without warranty of any kind, either expressed, implied, or *
* statutory, including, without limitation, warranties that the *
* Covered Software is free of defects, merchantable, fit for a *
* particular purpose or non-infringing. The entire risk as to the *
* quality and performance of the Covered Software is with You. *
* Should any Covered Software prove defective in any respect, You *
* (not any Contributor) assume the cost of any necessary servicing, *
* repair, or correction. This disclaimer of warranty constitutes an *
* essential part of this License. No use of any Covered Software is *
* authorized under this License except under this disclaimer. *
* *
************************************************************************
************************************************************************
* *
* 7. Limitation of Liability *
* -------------------------- *
* *
* Under no circumstances and under no legal theory, whether tort *
* (including negligence), contract, or otherwise, shall any *
* Contributor, or anyone who distributes Covered Software as *
* permitted above, be liable to You for any direct, indirect, *
* special, incidental, or consequential damages of any character *
* including, without limitation, damages for lost profits, loss of *
* goodwill, work stoppage, computer failure or malfunction, or any *
* and all other commercial damages or losses, even if such party *
* shall have been informed of the possibility of such damages. This *
* limitation of liability shall not apply to liability for death or *
* personal injury resulting from such party's negligence to the *
* extent applicable law prohibits such limitation. Some *
* jurisdictions do not allow the exclusion or limitation of *
* incidental or consequential damages, so this exclusion and *
* limitation may not apply to You. *
* *
************************************************************************
8. Litigation
-------------
Any litigation relating to this License may be brought only in the
courts of a jurisdiction where the defendant maintains its principal
place of business and such litigation shall be governed by laws of that
jurisdiction, without reference to its conflict-of-law provisions.
Nothing in this Section shall prevent a party's ability to bring
cross-claims or counter-claims.
9. Miscellaneous
----------------
This License represents the complete agreement concerning the subject
matter hereof. If any provision of this License is held to be
unenforceable, such provision shall be reformed only to the extent
necessary to make it enforceable. Any law or regulation which provides
that the language of a contract shall be construed against the drafter
shall not be used to construe this License against a Contributor.
10. Versions of the License
---------------------------
10.1. New Versions
Mozilla Foundation is the license steward. Except as provided in Section
10.3, no one other than the license steward has the right to modify or
publish new versions of this License. Each version will be given a
distinguishing version number.
10.2. Effect of New Versions
You may distribute the Covered Software under the terms of the version
of the License under which You originally received the Covered Software,
or under the terms of any subsequent version published by the license
steward.
10.3. Modified Versions
If you create software not governed by this License, and you want to
create a new license for such software, you may create and use a
modified version of this License if you rename the license and remove
any references to the name of the license steward (except to note that
such modified license differs from this License).
10.4. Distributing Source Code Form that is Incompatible With Secondary
Licenses
If You choose to distribute Source Code Form that is Incompatible With
Secondary Licenses under the terms of this version of the License, the
notice described in Exhibit B of this License must be attached.
Exhibit A - Source Code Form License Notice
-------------------------------------------
This Source Code Form is subject to the terms of the Mozilla Public
License, v. 2.0. If a copy of the MPL was not distributed with this
file, You can obtain one at http://mozilla.org/MPL/2.0/.
If it is not possible or desirable to put the notice in a particular
file, then You may include the notice in a location (such as a LICENSE
file in a relevant directory) where a recipient would be likely to look
for such a notice.
You may add additional accurate notices of copyright ownership.
Exhibit B - "Incompatible With Secondary Licenses" Notice
---------------------------------------------------------
This Source Code Form is "Incompatible With Secondary Licenses", as
defined by the Mozilla Public License, v. 2.0.
resvg-0.44.0/crates/resvg/README.md 0000777 0000000 0000000 00000000000 14675720665 0020535 2../../README.md ustar 00root root 0000000 0000000 resvg-0.44.0/crates/resvg/examples/ 0000775 0000000 0000000 00000000000 14675720665 0017174 5 ustar 00root root 0000000 0000000 resvg-0.44.0/crates/resvg/examples/bboxes.svg 0000664 0000000 0000000 00000005774 14675720665 0021214 0 ustar 00root root 0000000 0000000
resvg-0.44.0/crates/resvg/examples/custom_href_resolver.rs 0000664 0000000 0000000 00000002344 14675720665 0024004 0 ustar 00root root 0000000 0000000 fn main() {
let mut opt = usvg::Options::default();
let ferris_image = std::sync::Arc::new(std::fs::read("./examples/ferris.png").unwrap());
// We know that our SVG won't have DataUrl hrefs, just return None for such case.
let resolve_data = Box::new(|_: &str, _: std::sync::Arc>, _: &usvg::Options| None);
// Here we handle xlink:href attribute as string,
// let's use already loaded Ferris image to match that string.
let resolve_string = Box::new(move |href: &str, _: &usvg::Options| match href {
"ferris_image" => Some(usvg::ImageKind::PNG(ferris_image.clone())),
_ => None,
});
// Assign new ImageHrefResolver option using our closures.
opt.image_href_resolver = usvg::ImageHrefResolver {
resolve_data,
resolve_string,
};
let svg_data = std::fs::read("./examples/custom_href_resolver.svg").unwrap();
let tree = usvg::Tree::from_data(&svg_data, &opt).unwrap();
let pixmap_size = tree.size().to_int_size();
let mut pixmap = tiny_skia::Pixmap::new(pixmap_size.width(), pixmap_size.height()).unwrap();
resvg::render(&tree, tiny_skia::Transform::default(), &mut pixmap.as_mut());
pixmap.save_png("custom_href_resolver.png").unwrap();
}
resvg-0.44.0/crates/resvg/examples/custom_href_resolver.svg 0000664 0000000 0000000 00000000413 14675720665 0024152 0 ustar 00root root 0000000 0000000
resvg-0.44.0/crates/resvg/examples/draw_bboxes.rs 0000664 0000000 0000000 00000004557 14675720665 0022054 0 ustar 00root root 0000000 0000000 fn main() {
let args: Vec = std::env::args().collect();
if !(args.len() == 3 || args.len() == 5) {
println!(
"Usage:\n\
\tdraw_bboxes \n\
\tdraw_bboxes -z ZOOM"
);
return;
}
let zoom = if args.len() == 5 {
args[4].parse::().expect("not a float")
} else {
1.0
};
let mut opt = usvg::Options::default();
// Get file's absolute directory.
opt.resources_dir = std::fs::canonicalize(&args[1])
.ok()
.and_then(|p| p.parent().map(|p| p.to_path_buf()));
opt.fontdb_mut().load_system_fonts();
let svg_data = std::fs::read(&args[1]).unwrap();
let tree = usvg::Tree::from_data(&svg_data, &opt).unwrap();
let mut bboxes = Vec::new();
let mut stroke_bboxes = Vec::new();
collect_bboxes(tree.root(), &mut bboxes, &mut stroke_bboxes);
let pixmap_size = tree.size().to_int_size().scale_by(zoom).unwrap();
let mut pixmap = tiny_skia::Pixmap::new(pixmap_size.width(), pixmap_size.height()).unwrap();
let render_ts = tiny_skia::Transform::from_scale(zoom, zoom);
resvg::render(&tree, render_ts, &mut pixmap.as_mut());
let mut stroke = tiny_skia::Stroke::default();
stroke.width = 1.0 / zoom; // prevent stroke scaling as well
let mut paint1 = tiny_skia::Paint::default();
paint1.set_color_rgba8(255, 0, 0, 127);
let mut paint2 = tiny_skia::Paint::default();
paint2.set_color_rgba8(0, 200, 0, 127);
for bbox in bboxes {
let path = tiny_skia::PathBuilder::from_rect(bbox);
pixmap.stroke_path(&path, &paint1, &stroke, render_ts, None);
}
for bbox in stroke_bboxes {
let path = tiny_skia::PathBuilder::from_rect(bbox);
pixmap.stroke_path(&path, &paint2, &stroke, render_ts, None);
}
pixmap.save_png(&args[2]).unwrap();
}
fn collect_bboxes(
parent: &usvg::Group,
bboxes: &mut Vec,
stroke_bboxes: &mut Vec,
) {
for node in parent.children() {
if let usvg::Node::Group(ref group) = node {
collect_bboxes(group, bboxes, stroke_bboxes);
}
let bbox = node.abs_bounding_box();
bboxes.push(bbox);
let stroke_bbox = node.abs_stroke_bounding_box();
if bbox != stroke_bbox {
stroke_bboxes.push(stroke_bbox);
}
}
}
resvg-0.44.0/crates/resvg/examples/ferris.png 0000664 0000000 0000000 00000102110 14675720665 0021167 0 ustar 00root root 0000000 0000000 ‰PNG
IHDR ° 3à› „IDATxìÁ € ý©© `öî븑ûÛ÷è¡C@!0„ÀëŽ7é\‘ÁȾ"†€BèëôÜ÷[ÿÂQƈl Ú¬©Zãø¶?õÛ»‡ñëÿýV«ÏXF ðòáq MÜÇ>º¿ÐÆ.î¢ ¸tÀ ‰M´Ñõt² .° XÆ1ºgùµ¢‰: † ð±ßjýx˜êåË¨ç ° XGwm,¢ ° εŒî‚ÑD ` ôÕÄ1ºÛF ` ôµ‰îJVQ XO °ˆîb~ùÄ!êi 0 €_kß?H=Û}Ô8 X ÀoÕÄ:âÝÚØÇ6–Q<Ã/uwŠR×ÖFu&~®&Ö±‹}thcÛ¸‹/ À `H~«Eì¢ëᘠ³Ž¢ŸS@:Fw#Û¨Þ„«Eì¢ë¡ý?Õ&š¨q †à·jbÝŸüÚ˱÷qpkÝ-£žL¼ÚD÷‰Ÿž¬»( @À žê×ZÄ!º²‰z”xµˆn öQ<â§jbÝÙE