pax_global_header 0000666 0000000 0000000 00000000064 15000020642 0014477 g ustar 00root root 0000000 0000000 52 comment=fd841e1c0a173dcf90be04c45f294fe3aa3bb1eb
linebender-resvg-fd841e1/ 0000775 0000000 0000000 00000000000 15000020642 0015350 5 ustar 00root root 0000000 0000000 linebender-resvg-fd841e1/.github/ 0000775 0000000 0000000 00000000000 15000020642 0016710 5 ustar 00root root 0000000 0000000 linebender-resvg-fd841e1/.github/chart-svg2.svg 0000664 0000000 0000000 00000006315 15000020642 0021416 0 ustar 00root root 0000000 0000000
linebender-resvg-fd841e1/.github/chart.svg 0000664 0000000 0000000 00000006241 15000020642 0020535 0 ustar 00root root 0000000 0000000
linebender-resvg-fd841e1/.github/copyright.sh 0000664 0000000 0000000 00000001527 15000020642 0021261 0 ustar 00root root 0000000 0000000 #!/bin/bash
# If there are new files with headers that can't match the conditions here,
# then the files can be ignored by an additional glob argument via the -g flag.
# For example:
# -g "!src/special_file.rs"
# -g "!src/special_directory"
# Check all the standard Rust source files
output=$(rg "^// Copyright (19|20)[\d]{2} (.+ and )?the Resvg Authors( and .+)?$\n^// SPDX-License-Identifier: Apache-2\.0 OR MIT$\n\n" --files-without-match --multiline -g "*.{rs,c,cpp,h}" .)
if [ -n "$output" ]; then
echo -e "The following files lack the correct copyright header:\n"
echo $output
echo -e "\n\nPlease add the following header:\n"
echo "// Copyright $(date +%Y) the Resvg Authors"
echo "// SPDX-License-Identifier: Apache-2.0 OR MIT"
echo -e "\n... rest of the file ...\n"
exit 1
fi
echo "All files have correct copyright headers."
exit 0
linebender-resvg-fd841e1/.github/pull_request_template.md 0000664 0000000 0000000 00000000413 15000020642 0023647 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.
linebender-resvg-fd841e1/.github/workflows/ 0000775 0000000 0000000 00000000000 15000020642 0020745 5 ustar 00root root 0000000 0000000 linebender-resvg-fd841e1/.github/workflows/main.yml 0000664 0000000 0000000 00000005441 15000020642 0022420 0 ustar 00root root 0000000 0000000 name: Build
on: [push, pull_request]
env:
CARGO_TERM_COLOR: always
jobs:
fmt:
name: formatting
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
# TODO: Enable this when more of the Linebender CI has been applied.
#- name: install stable toolchain
# uses: dtolnay/rust-toolchain@master
# with:
# toolchain: ${{ env.RUST_STABLE_VER }}
# components: rustfmt
- name: cargo fmt
run: cargo fmt --all --check
- name: install ripgrep
run: |
sudo apt update
sudo apt install ripgrep
- name: check copyright headers
run: bash .github/copyright.sh
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
# If this fails, consider changing your text or adding something to .typos.toml.
typos:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: check typos
uses: crate-ci/typos@v1.28.4
linebender-resvg-fd841e1/.github/workflows/tagged-release.yml 0000664 0000000 0000000 00000012627 15000020642 0024351 0 ustar 00root root 0000000 0000000 name: "Tagged Release"
on:
push:
tags:
- "v*"
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_name }}
body: |
- `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/linebender/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/linebender/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"
# 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: 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/
- 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-13
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: Collect
run: |
mkdir bin
cp target/release/resvg-macos-x86_64.zip bin/
cp target/release/usvg-macos-x86_64.zip bin/
- name: Upload binaries
uses: alexellis/upload-assets@0.2.2
env:
GITHUB_TOKEN: ${{ github.token }}
with:
asset_paths: '["bin/*"]'
linebender-resvg-fd841e1/.gitignore 0000664 0000000 0000000 00000000062 15000020642 0017336 0 ustar 00root root 0000000 0000000 target
.directory
.DS_Store
.vscode
tools/build-*
linebender-resvg-fd841e1/.typos.toml 0000664 0000000 0000000 00000001424 15000020642 0017502 0 ustar 00root root 0000000 0000000 # See the configuration reference at
# https://github.com/crate-ci/typos/blob/master/docs/reference.md
# Corrections take the form of a key/value pair. The key is the incorrect word
# and the value is the correct word. If the key and value are the same, the
# word is treated as always correct. If the value is an empty string, the word
# is treated as always incorrect.
# Match Identifier - Case Sensitive
[default.extend-identifiers]
ba = "ba"
flate2 = "flate2"
Hel = "Hel"
PNGs = "PNGs"
SVGinOT = "SVGinOT"
# Match Inside a Word - Case Insensitive
[default.extend-words]
[files]
# Include .github, .cargo, etc.
ignore-hidden = false
extend-exclude = [
# /.git isn't in .gitignore, because git never tracks it.
# Typos doesn't know that, though.
"/.git",
"*.svg",
]
linebender-resvg-fd841e1/AUTHORS 0000664 0000000 0000000 00000000477 15000020642 0016430 0 ustar 00root root 0000000 0000000 # This is the list of Resvg's significant contributors.
#
# This does not necessarily list everyone who has contributed code,
# especially since many employees of one corporation may be contributing.
# To see the full list of contributors, see the revision history in
# source control.
Yevhenii Reizner
Laurenz Stampfl
linebender-resvg-fd841e1/CHANGELOG.md 0000664 0000000 0000000 00000164654 15000020642 0017201 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]
This release has an MSRV of 1.65 for `usvg` and 1.67.1 for `resvg` and the C API.
### Added
- Support SVGs without the xmlns attribute on the root. Thanks to [@JosefKuchar][].
### Removed
- tools/kde-dolphin-thumbnailer. This was never a released tool, and it doesn't support current versions of KDE/dolphin ([#897][] by [@DJMcNab][])
## [0.45.0] - 2025-02-26
This is the first release under the stewardship of [Linebender][], who is now responsible for maintenance of this crate.
Many thanks to Yevhenii Reizner for the years of hard work that he has poured into this and other crates.
Please note that the license of this project changed from `MPL-2.0` to `Apache-2.0 OR MIT`.
See [resvg#838](https://github.com/linebender/resvg/issues/838) for more information.
This release has an MSRV of 1.65 for `usvg` and 1.67.1 for `resvg` and the C API.
### Added
- Support for the `background-color` attribute.
- Support for additional `image-rendering` attributes.
- Support for the `!important` CSS flag.
- Support for Luma JPEG images.
- (c-api) `resvg_options_set_stylesheet`.
Thanks to [@michabay05][].
- (svgtypes) Support for floating point hue in `hsl()` and `hsla()`.
### Changed
- License to `Apache-2.0 OR MIT`.
See [resvg#838](https://github.com/linebender/resvg/issues/838) for more information.
- Updated WebP decoder for bug fixes and improved performance.
Thanks to [@Shnatsel][].
- MSRV of resvg and c-api bumped to 1.67.1.
- `fontdb` and `rustybuzz` have been updated.
- Updated other dependencies.
- (svgtypes) Simplified color component rounding and bounds checking.
- Improved handling of paths with paint order `markers` but no actual markers.
### Fixed
- Relative unit handling when `use` references `symbol`.
- (svgtypes) Rounding of hues in HSL to RGB conversion.
- (svgtypes) Rounding of alpha.
## [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/linebender/resvg/blob/main/crates/usvg/docs/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 `objectBoundingBox` 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 `objectBoundingBox` 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.
[Linebender]: https://github.com/linebender
[@DJMcNab]: https://github.com/DJMcNab
[@michabay05]: https://github.com/michabay05
[@Shnatsel]: https://github.com/Shnatsel
[@JosefKuchar]: https://github.com/JosefKuchar
[#897]: https://github.com/linebender/resvg/pull/897
[Unreleased]: https://github.com/linebender/resvg/compare/v0.45.1...HEAD
[0.45.1]: https://github.com/linebender/resvg/compare/v0.45.0...v0.45.1
[0.45.0]: https://github.com/linebender/resvg/compare/v0.44.0...v0.45.0
[0.44.0]: https://github.com/linebender/resvg/compare/v0.43.0...v0.44.0
[0.43.0]: https://github.com/linebender/resvg/compare/v0.42.0...v0.43.0
[0.42.0]: https://github.com/linebender/resvg/compare/v0.41.0...v0.42.0
[0.41.0]: https://github.com/linebender/resvg/compare/v0.40.0...v0.41.0
[0.40.0]: https://github.com/linebender/resvg/compare/v0.39.0...v0.40.0
[0.39.0]: https://github.com/linebender/resvg/compare/v0.38.0...v0.39.0
[0.38.0]: https://github.com/linebender/resvg/compare/v0.37.0...v0.38.0
[0.37.0]: https://github.com/linebender/resvg/compare/v0.36.0...v0.37.0
[0.36.0]: https://github.com/linebender/resvg/compare/v0.35.0...v0.36.0
[0.35.0]: https://github.com/linebender/resvg/compare/v0.34.1...v0.35.0
[0.34.1]: https://github.com/linebender/resvg/compare/v0.34.0...v0.34.1
[0.34.0]: https://github.com/linebender/resvg/compare/v0.33.0...v0.34.0
[0.33.0]: https://github.com/linebender/resvg/compare/v0.32.0...v0.33.0
[0.32.0]: https://github.com/linebender/resvg/compare/v0.31.1...v0.32.0
[0.31.1]: https://github.com/linebender/resvg/compare/v0.31.0...v0.31.1
[0.31.0]: https://github.com/linebender/resvg/compare/v0.30.0...v0.31.0
[0.30.0]: https://github.com/linebender/resvg/compare/v0.29.0...v0.30.0
[0.29.0]: https://github.com/linebender/resvg/compare/v0.28.0...v0.29.0
[0.28.0]: https://github.com/linebender/resvg/compare/v0.27.0...v0.28.0
[0.27.0]: https://github.com/linebender/resvg/compare/v0.26.1...v0.27.0
[0.26.1]: https://github.com/linebender/resvg/compare/v0.26.0...v0.26.1
[0.26.0]: https://github.com/linebender/resvg/compare/v0.25.0...v0.26.0
[0.25.0]: https://github.com/linebender/resvg/compare/v0.24.0...v0.25.0
[0.24.0]: https://github.com/linebender/resvg/compare/v0.23.0...v0.24.0
[0.23.0]: https://github.com/linebender/resvg/compare/v0.22.0...v0.23.0
[0.22.0]: https://github.com/linebender/resvg/compare/v0.21.0...v0.22.0
[0.21.0]: https://github.com/linebender/resvg/compare/v0.20.0...v0.21.0
[0.20.0]: https://github.com/linebender/resvg/compare/v0.19.0...v0.20.0
[0.19.0]: https://github.com/linebender/resvg/compare/v0.18.0...v0.19.0
[0.18.0]: https://github.com/linebender/resvg/compare/v0.17.0...v0.18.0
[0.17.0]: https://github.com/linebender/resvg/compare/v0.16.0...v0.17.0
[0.16.0]: https://github.com/linebender/resvg/compare/v0.15.0...v0.16.0
[0.15.0]: https://github.com/linebender/resvg/compare/v0.14.1...v0.15.0
[0.14.1]: https://github.com/linebender/resvg/compare/v0.14.0...v0.14.1
[0.14.0]: https://github.com/linebender/resvg/compare/v0.13.1...v0.14.0
[0.13.1]: https://github.com/linebender/resvg/compare/v0.13.0...v0.13.1
[0.13.0]: https://github.com/linebender/resvg/compare/v0.12.0...v0.13.0
[0.12.0]: https://github.com/linebender/resvg/compare/v0.11.0...v0.12.0
[0.11.0]: https://github.com/linebender/resvg/compare/v0.10.0...v0.11.0
[0.10.0]: https://github.com/linebender/resvg/compare/v0.9.1...v0.10.0
[0.9.1]: https://github.com/linebender/resvg/compare/v0.9.0...v0.9.1
[0.9.0]: https://github.com/linebender/resvg/compare/v0.8.0...v0.9.0
[0.8.0]: https://github.com/linebender/resvg/compare/v0.7.0...v0.8.0
[0.7.0]: https://github.com/linebender/resvg/compare/v0.6.1...v0.7.0
[0.6.1]: https://github.com/linebender/resvg/compare/v0.6.0...v0.6.1
[0.6.0]: https://github.com/linebender/resvg/compare/v0.5.0...v0.6.0
[0.5.0]: https://github.com/linebender/resvg/compare/v0.4.0...v0.5.0
[0.4.0]: https://github.com/linebender/resvg/compare/v0.3.0...v0.4.0
[0.3.0]: https://github.com/linebender/resvg/compare/v0.2.0...v0.3.0
[0.2.0]: https://github.com/linebender/resvg/compare/v0.1.0...v0.2.0
linebender-resvg-fd841e1/Cargo.lock 0000664 0000000 0000000 00000044775 15000020642 0017276 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 = "autocfg"
version = "0.1.8"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "0dde43e75fd43e8a1bf86103336bc699aa8d17ad1be60c76c0bdfd4828e19b78"
dependencies = [
"autocfg 1.4.0",
]
[[package]]
name = "autocfg"
version = "1.4.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "ace50bade8e6234aa140d9a2f552bbee1db4d353f69b8217bc503490fc1a9f26"
[[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.8.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "8f68f53c83ab957f72c32642f3868eec03eb974d1fb82e453128456482613d36"
[[package]]
name = "bytemuck"
version = "1.21.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "ef657dfab802224e671f5818e9a4935f9b1957ed18e58292690cc39e7a4092a3"
[[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 = "cloudabi"
version = "0.0.3"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "ddfc5b9aa5d4507acaf872de71051dfd0e309860e88966e1051e462a077aac4f"
dependencies = [
"bitflags 1.3.2",
]
[[package]]
name = "codegen"
version = "0.1.0"
dependencies = [
"itertools",
"phf",
"phf_codegen",
]
[[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.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "77745e017f5edba1a9c1d854f6f3a52dac8a12dd5af5d2f54aecf61e43d80d30"
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 = "either"
version = "1.14.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "b7914353092ddf589ad78f25c5c1c21b7f80b0ff8621e7c814c3485b5306da9d"
[[package]]
name = "fdeflate"
version = "0.3.7"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "1e6853b52649d4ac5c0bd02320cddc5ba956bdb407c4b75a2c6b75bf51500f8c"
dependencies = [
"simd-adler32",
]
[[package]]
name = "flate2"
version = "1.1.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "11faaf5a5236997af9848be0bef4db95824b1d534ebc64d0f0c6cf3e67bd38dc"
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.23.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "457e789b3d1202543297a350643cf459f836cade38934e7a4cf6a39e7cde2905"
dependencies = [
"fontconfig-parser",
"log",
"memmap2",
"slotmap",
"tinyvec",
"ttf-parser",
]
[[package]]
name = "fuchsia-cprng"
version = "0.1.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "a06f77d526c1a601b7c4cdd98f54b5eaabffc14d5f2f0296febdc7f357c6d3ba"
[[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.2.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "e031e8e3d94711a9ccb5d6ea357439ef3dcbed361798bd4071dc4d9793fbe22f"
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 = "itertools"
version = "0.14.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "2b192c782037fadd9cfa75548310488aabdbf3d2da73885b31bd0abd03351285"
dependencies = [
"either",
]
[[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.170"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "875b3680cb2f8f71bdcf9a30f38d48282f5d3c95cbf9b3fa57269bb5d5c06828"
[[package]]
name = "libm"
version = "0.2.11"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "8355be11b20d696c8f18f6cc018c4e372165b1fa8126cef092399c9951984ffa"
[[package]]
name = "log"
version = "0.4.26"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "30bde2b3dc3671ae49d8e2e9f044c7c005836e7a023ee57cffa25ab82764bb9e"
[[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.5"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "8e3e04debbb59698c15bacbb6d93584a8c0ca9cc3213cb423d31f760d8843ce5"
dependencies = [
"adler2",
"simd-adler32",
]
[[package]]
name = "once_cell"
version = "1.20.3"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "945462a4b81e43c4e3ba96bd7b49d834c6f61198356aa858733bc4acf3cbe62e"
[[package]]
name = "phf"
version = "0.7.24"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "b3da44b85f8e8dfaec21adae67f95d93244b2ecf6ad2a692320598dcc8e6dd18"
dependencies = [
"phf_shared",
]
[[package]]
name = "phf_codegen"
version = "0.7.24"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "b03e85129e324ad4166b06b2c7491ae27fe3ec353af72e72cd1654c7225d517e"
dependencies = [
"phf_generator",
"phf_shared",
]
[[package]]
name = "phf_generator"
version = "0.7.24"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "09364cc93c159b8b06b1f4dd8a4398984503483891b0c26b867cf431fb132662"
dependencies = [
"phf_shared",
"rand",
]
[[package]]
name = "phf_shared"
version = "0.7.24"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "234f71a15de2288bcb7e3b6515828d22af7ec8598ee6d24c3b526fa0a80b67a0"
dependencies = [
"siphasher 0.2.3",
]
[[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.16"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "82151a2fc869e011c153adc57cf2789ccb8d9906ce52c0b39a6b5697749d7526"
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 = "rand"
version = "0.6.5"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "6d71dacdc3c88c1fde3885a3be3fbab9f35724e6ce99467f7d9c5026132184ca"
dependencies = [
"autocfg 0.1.8",
"libc",
"rand_chacha",
"rand_core 0.4.2",
"rand_hc",
"rand_isaac",
"rand_jitter",
"rand_os",
"rand_pcg",
"rand_xorshift",
"winapi",
]
[[package]]
name = "rand_chacha"
version = "0.1.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "556d3a1ca6600bfcbab7c7c91ccb085ac7fbbcd70e008a98742e7847f4f7bcef"
dependencies = [
"autocfg 0.1.8",
"rand_core 0.3.1",
]
[[package]]
name = "rand_core"
version = "0.3.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "7a6fdeb83b075e8266dcc8762c22776f6877a63111121f5f8c7411e5be7eed4b"
dependencies = [
"rand_core 0.4.2",
]
[[package]]
name = "rand_core"
version = "0.4.2"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "9c33a3c44ca05fa6f1807d8e6743f3824e8509beca625669633be0acbdf509dc"
[[package]]
name = "rand_hc"
version = "0.1.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "7b40677c7be09ae76218dc623efbf7b18e34bced3f38883af07bb75630a21bc4"
dependencies = [
"rand_core 0.3.1",
]
[[package]]
name = "rand_isaac"
version = "0.1.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "ded997c9d5f13925be2a6fd7e66bf1872597f759fd9dd93513dd7e92e5a5ee08"
dependencies = [
"rand_core 0.3.1",
]
[[package]]
name = "rand_jitter"
version = "0.1.4"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "1166d5c91dc97b88d1decc3285bb0a99ed84b05cfd0bc2341bdf2d43fc41e39b"
dependencies = [
"libc",
"rand_core 0.4.2",
"winapi",
]
[[package]]
name = "rand_os"
version = "0.1.3"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "7b75f676a1e053fc562eafbb47838d67c84801e38fc1ba459e8f180deabd5071"
dependencies = [
"cloudabi",
"fuchsia-cprng",
"libc",
"rand_core 0.4.2",
"rdrand",
"winapi",
]
[[package]]
name = "rand_pcg"
version = "0.1.2"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "abf9b09b01790cfe0364f52bf32995ea3c39f4d2dd011eac241d2914146d0b44"
dependencies = [
"autocfg 0.1.8",
"rand_core 0.4.2",
]
[[package]]
name = "rand_xorshift"
version = "0.1.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "cbf7e9e623549b0e21f6e97cf8ecf247c1a8fd2e8a992ae265314300b2455d5c"
dependencies = [
"rand_core 0.3.1",
]
[[package]]
name = "rdrand"
version = "0.4.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "678054eb77286b51581ba43620cc911abf02758c91f93f479767aed0f90458b2"
dependencies = [
"rand_core 0.3.1",
]
[[package]]
name = "resvg"
version = "0.45.1"
dependencies = [
"gif",
"image-webp",
"log",
"once_cell",
"pico-args",
"png",
"rgb",
"svgtypes",
"tiny-skia",
"usvg",
"zune-jpeg",
]
[[package]]
name = "resvg-capi"
version = "0.45.1"
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.20.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "fd3c7c96f8a08ee34eff8857b11b49b07d71d1c3f4e88f8a88d4c9e9f90b1702"
dependencies = [
"bitflags 2.8.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.2"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "7a9c6883ca9c3c7c90e888de77b7a5c849c779d25d74a1269b0218b14e8b136c"
dependencies = [
"log",
]
[[package]]
name = "siphasher"
version = "0.2.3"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "0b8de496cf83d4ed58b6be86c3a275b8602f6ffe98d3024a869e124147a9a3ac"
[[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.14.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "7fcf8323ef1faaee30a44a340193b1ac6814fd9b7b4e88e9d4519a3e4abe1cfd"
[[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.3"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "68c7541fff44b35860c1a7a47a7cadf3e4a304c457b58f9870d9706ece028afc"
dependencies = [
"kurbo",
"siphasher 1.0.1",
]
[[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.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "022db8904dfa342efe721985167e9fcd16c29b226db4397ed752a761cfce81e8"
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.25.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "d2df906b07856748fa3f6e0ad0cbaa047052d4a7dd609e231c4f72cee8c36f31"
dependencies = [
"core_maths",
]
[[package]]
name = "unicode-bidi"
version = "0.3.18"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "5c1cb5db39152898a79168971543b1cb5020dff7fe43c8dc468b0885f5e29df5"
[[package]]
name = "unicode-bidi-mirroring"
version = "0.4.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "5dfa6e8c60bb66d49db113e0125ee8711b7647b5579dc7f5f19c42357ed039fe"
[[package]]
name = "unicode-ccc"
version = "0.4.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "ce61d488bcdc9bc8b5d1772c404828b17fc481c0a582b5581e95fb233aef503e"
[[package]]
name = "unicode-properties"
version = "0.1.3"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "e70f2a8b45122e719eb623c01822704c4e0907e7e426a05927e1a1cfff5b75d0"
[[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.45.1"
dependencies = [
"base64",
"data-url",
"flate2",
"fontdb",
"imagesize",
"kurbo",
"log",
"once_cell",
"pico-args",
"roxmltree",
"rustybuzz",
"simplecss",
"siphasher 1.0.1",
"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 = "winapi"
version = "0.3.9"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "5c839a674fcd7a98952e593242ea400abe93992746761e38641405d28b00f419"
dependencies = [
"winapi-i686-pc-windows-gnu",
"winapi-x86_64-pc-windows-gnu",
]
[[package]]
name = "winapi-i686-pc-windows-gnu"
version = "0.4.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "ac3b87c63620426dd9b991e5ce0329eff545bccbbb34f3be09ff6fb6ab51b7b6"
[[package]]
name = "winapi-x86_64-pc-windows-gnu"
version = "0.4.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "712e227841d057c1ee1cd2fb22fa7e5a5461ae8e48fa2ca79ec42cfc1931183f"
[[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.14"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "99a5bab8d7dedf81405c4bb1f2b83ea057643d9cb28778cea9eecddeedd2e028"
dependencies = [
"zune-core",
]
linebender-resvg-fd841e1/Cargo.toml 0000664 0000000 0000000 00000000370 15000020642 0017300 0 ustar 00root root 0000000 0000000 [workspace]
members = [
"crates/c-api",
"crates/resvg",
"crates/usvg",
"crates/usvg/codegen",
#"tools/explorer-thumbnailer",
]
default-members = ["crates/resvg"]
resolver = "2"
[workspace.package]
license = "Apache-2.0 OR MIT"
linebender-resvg-fd841e1/LICENSE-APACHE 0000664 0000000 0000000 00000023675 15000020642 0017311 0 ustar 00root root 0000000 0000000 Apache License
Version 2.0, January 2004
http://www.apache.org/licenses/
TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
1. Definitions.
"License" shall mean the terms and conditions for use, reproduction,
and distribution as defined by Sections 1 through 9 of this document.
"Licensor" shall mean the copyright owner or entity authorized by
the copyright owner that is granting the License.
"Legal Entity" shall mean the union of the acting entity and all
other entities that control, are controlled by, or are under common
control with that entity. For the purposes of this definition,
"control" means (i) the power, direct or indirect, to cause the
direction or management of such entity, whether by contract or
otherwise, or (ii) ownership of fifty percent (50%) or more of the
outstanding shares, or (iii) beneficial ownership of such entity.
"You" (or "Your") shall mean an individual or Legal Entity
exercising permissions granted by this License.
"Source" form shall mean the preferred form for making modifications,
including but not limited to software source code, documentation
source, and configuration files.
"Object" form shall mean any form resulting from mechanical
transformation or translation of a Source form, including but
not limited to compiled object code, generated documentation,
and conversions to other media types.
"Work" shall mean the work of authorship, whether in Source or
Object form, made available under the License, as indicated by a
copyright notice that is included in or attached to the work
(an example is provided in the Appendix below).
"Derivative Works" shall mean any work, whether in Source or Object
form, that is based on (or derived from) the Work and for which the
editorial revisions, annotations, elaborations, or other modifications
represent, as a whole, an original work of authorship. For the purposes
of this License, Derivative Works shall not include works that remain
separable from, or merely link (or bind by name) to the interfaces of,
the Work and Derivative Works thereof.
"Contribution" shall mean any work of authorship, including
the original version of the Work and any modifications or additions
to that Work or Derivative Works thereof, that is intentionally
submitted to Licensor for inclusion in the Work by the copyright owner
or by an individual or Legal Entity authorized to submit on behalf of
the copyright owner. For the purposes of this definition, "submitted"
means any form of electronic, verbal, or written communication sent
to the Licensor or its representatives, including but not limited to
communication on electronic mailing lists, source code control systems,
and issue tracking systems that are managed by, or on behalf of, the
Licensor for the purpose of discussing and improving the Work, but
excluding communication that is conspicuously marked or otherwise
designated in writing by the copyright owner as "Not a Contribution."
"Contributor" shall mean Licensor and any individual or Legal Entity
on behalf of whom a Contribution has been received by Licensor and
subsequently incorporated within the Work.
2. Grant of Copyright License. Subject to the terms and conditions of
this License, each Contributor hereby grants to You a perpetual,
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
copyright license to reproduce, prepare Derivative Works of,
publicly display, publicly perform, sublicense, and distribute the
Work and such Derivative Works in Source or Object form.
3. Grant of Patent License. Subject to the terms and conditions of
this License, each Contributor hereby grants to You a perpetual,
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
(except as stated in this section) patent license to make, have made,
use, offer to sell, sell, import, and otherwise transfer the Work,
where such license applies only to those patent claims licensable
by such Contributor that are necessarily infringed by their
Contribution(s) alone or by combination of their Contribution(s)
with the Work to which such Contribution(s) was submitted. If You
institute patent litigation against any entity (including a
cross-claim or counterclaim in a lawsuit) alleging that the Work
or a Contribution incorporated within the Work constitutes direct
or contributory patent infringement, then any patent licenses
granted to You under this License for that Work shall terminate
as of the date such litigation is filed.
4. Redistribution. You may reproduce and distribute copies of the
Work or Derivative Works thereof in any medium, with or without
modifications, and in Source or Object form, provided that You
meet the following conditions:
(a) You must give any other recipients of the Work or
Derivative Works a copy of this License; and
(b) You must cause any modified files to carry prominent notices
stating that You changed the files; and
(c) You must retain, in the Source form of any Derivative Works
that You distribute, all copyright, patent, trademark, and
attribution notices from the Source form of the Work,
excluding those notices that do not pertain to any part of
the Derivative Works; and
(d) If the Work includes a "NOTICE" text file as part of its
distribution, then any Derivative Works that You distribute must
include a readable copy of the attribution notices contained
within such NOTICE file, excluding those notices that do not
pertain to any part of the Derivative Works, in at least one
of the following places: within a NOTICE text file distributed
as part of the Derivative Works; within the Source form or
documentation, if provided along with the Derivative Works; or,
within a display generated by the Derivative Works, if and
wherever such third-party notices normally appear. The contents
of the NOTICE file are for informational purposes only and
do not modify the License. You may add Your own attribution
notices within Derivative Works that You distribute, alongside
or as an addendum to the NOTICE text from the Work, provided
that such additional attribution notices cannot be construed
as modifying the License.
You may add Your own copyright statement to Your modifications and
may provide additional or different license terms and conditions
for use, reproduction, or distribution of Your modifications, or
for any such Derivative Works as a whole, provided Your use,
reproduction, and distribution of the Work otherwise complies with
the conditions stated in this License.
5. Submission of Contributions. Unless You explicitly state otherwise,
any Contribution intentionally submitted for inclusion in the Work
by You to the Licensor shall be under the terms and conditions of
this License, without any additional terms or conditions.
Notwithstanding the above, nothing herein shall supersede or modify
the terms of any separate license agreement you may have executed
with Licensor regarding such Contributions.
6. Trademarks. This License does not grant permission to use the trade
names, trademarks, service marks, or product names of the Licensor,
except as required for reasonable and customary use in describing the
origin of the Work and reproducing the content of the NOTICE file.
7. Disclaimer of Warranty. Unless required by applicable law or
agreed to in writing, Licensor provides the Work (and each
Contributor provides its Contributions) on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
implied, including, without limitation, any warranties or conditions
of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
PARTICULAR PURPOSE. You are solely responsible for determining the
appropriateness of using or redistributing the Work and assume any
risks associated with Your exercise of permissions under this License.
8. Limitation of Liability. In no event and under no legal theory,
whether in tort (including negligence), contract, or otherwise,
unless required by applicable law (such as deliberate and grossly
negligent acts) or agreed to in writing, shall any Contributor be
liable to You for damages, including any direct, indirect, special,
incidental, or consequential damages of any character arising as a
result of this License or out of the use or inability to use the
Work (including but not limited to damages for loss of goodwill,
work stoppage, computer failure or malfunction, or any and all
other commercial damages or losses), even if such Contributor
has been advised of the possibility of such damages.
9. Accepting Warranty or Additional Liability. While redistributing
the Work or Derivative Works thereof, You may choose to offer,
and charge a fee for, acceptance of support, warranty, indemnity,
or other liability obligations and/or rights consistent with this
License. However, in accepting such obligations, You may act only
on Your own behalf and on Your sole responsibility, not on behalf
of any other Contributor, and only if You agree to indemnify,
defend, and hold each Contributor harmless for any liability
incurred by, or claims asserted against, such Contributor by reason
of your accepting any such warranty or additional liability.
END OF TERMS AND CONDITIONS
linebender-resvg-fd841e1/LICENSE-MIT 0000664 0000000 0000000 00000002041 15000020642 0017001 0 ustar 00root root 0000000 0000000 Copyright 2017 the Resvg Authors
Permission is hereby granted, free of charge, to any
person obtaining a copy of this software and associated
documentation files (the "Software"), to deal in the
Software without restriction, including without
limitation the rights to use, copy, modify, merge,
publish, distribute, sublicense, and/or sell copies of
the Software, and to permit persons to whom the Software
is furnished to do so, subject to the following
conditions:
The above copyright notice and this permission notice
shall be included in all copies or substantial portions
of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF
ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED
TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A
PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT
SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR
IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
DEALINGS IN THE SOFTWARE.
linebender-resvg-fd841e1/README.md 0000664 0000000 0000000 00000016322 15000020642 0016633 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/linebender/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/linebender/resvg/issues?q=is%3Aissue+is%3Aopen+label%3Asvg2)
or our [SVG 2 changelog](https://github.com/linebender/resvg/blob/main/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/linebender/resvg-test-suite):

SVG 2 only results:

You can find a complete table of supported features
[here](https://linebender.org/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
Licensed under either of
- Apache License, Version 2.0 ([LICENSE-APACHE](LICENSE-APACHE) or )
- MIT license ([LICENSE-MIT](LICENSE-MIT) or )
at your option.
## Contribution
Contributions are welcome by pull request.
The [Rust code of conduct] applies.
Unless you explicitly state otherwise, any contribution intentionally submitted for inclusion in the work by you, as defined in the Apache-2.0 license, shall be licensed as above, without any additional terms or conditions.
[usvg]: https://github.com/linebender/resvg/tree/main/crates/usvg
[rustybuzz]: https://github.com/harfbuzz/rustybuzz
[tiny-skia]: https://github.com/linebender/tiny-skia
[ttf-parser]: https://github.com/harfbuzz/ttf-parser
[roxmltree]: https://github.com/RazrFalcon/roxmltree
[simplecss]: https://github.com/linebender/simplecss
[fontdb]: https://github.com/RazrFalcon/fontdb
[pico-args]: https://github.com/RazrFalcon/pico-args
[Rust Code of Conduct]: https://www.rust-lang.org/policies/code-of-conduct
linebender-resvg-fd841e1/crates/ 0000775 0000000 0000000 00000000000 15000020642 0016631 5 ustar 00root root 0000000 0000000 linebender-resvg-fd841e1/crates/c-api/ 0000775 0000000 0000000 00000000000 15000020642 0017622 5 ustar 00root root 0000000 0000000 linebender-resvg-fd841e1/crates/c-api/Cargo.toml 0000664 0000000 0000000 00000001547 15000020642 0021561 0 ustar 00root root 0000000 0000000 [package]
name = "resvg-capi"
version = "0.45.1"
keywords = ["svg", "render", "raster", "c-api"]
license.workspace = true
edition = "2021"
rust-version = "1.67.1"
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" }]
linebender-resvg-fd841e1/crates/c-api/LICENSE-APACHE 0000664 0000000 0000000 00000023675 15000020642 0021563 0 ustar 00root root 0000000 0000000 Apache License
Version 2.0, January 2004
http://www.apache.org/licenses/
TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
1. Definitions.
"License" shall mean the terms and conditions for use, reproduction,
and distribution as defined by Sections 1 through 9 of this document.
"Licensor" shall mean the copyright owner or entity authorized by
the copyright owner that is granting the License.
"Legal Entity" shall mean the union of the acting entity and all
other entities that control, are controlled by, or are under common
control with that entity. For the purposes of this definition,
"control" means (i) the power, direct or indirect, to cause the
direction or management of such entity, whether by contract or
otherwise, or (ii) ownership of fifty percent (50%) or more of the
outstanding shares, or (iii) beneficial ownership of such entity.
"You" (or "Your") shall mean an individual or Legal Entity
exercising permissions granted by this License.
"Source" form shall mean the preferred form for making modifications,
including but not limited to software source code, documentation
source, and configuration files.
"Object" form shall mean any form resulting from mechanical
transformation or translation of a Source form, including but
not limited to compiled object code, generated documentation,
and conversions to other media types.
"Work" shall mean the work of authorship, whether in Source or
Object form, made available under the License, as indicated by a
copyright notice that is included in or attached to the work
(an example is provided in the Appendix below).
"Derivative Works" shall mean any work, whether in Source or Object
form, that is based on (or derived from) the Work and for which the
editorial revisions, annotations, elaborations, or other modifications
represent, as a whole, an original work of authorship. For the purposes
of this License, Derivative Works shall not include works that remain
separable from, or merely link (or bind by name) to the interfaces of,
the Work and Derivative Works thereof.
"Contribution" shall mean any work of authorship, including
the original version of the Work and any modifications or additions
to that Work or Derivative Works thereof, that is intentionally
submitted to Licensor for inclusion in the Work by the copyright owner
or by an individual or Legal Entity authorized to submit on behalf of
the copyright owner. For the purposes of this definition, "submitted"
means any form of electronic, verbal, or written communication sent
to the Licensor or its representatives, including but not limited to
communication on electronic mailing lists, source code control systems,
and issue tracking systems that are managed by, or on behalf of, the
Licensor for the purpose of discussing and improving the Work, but
excluding communication that is conspicuously marked or otherwise
designated in writing by the copyright owner as "Not a Contribution."
"Contributor" shall mean Licensor and any individual or Legal Entity
on behalf of whom a Contribution has been received by Licensor and
subsequently incorporated within the Work.
2. Grant of Copyright License. Subject to the terms and conditions of
this License, each Contributor hereby grants to You a perpetual,
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
copyright license to reproduce, prepare Derivative Works of,
publicly display, publicly perform, sublicense, and distribute the
Work and such Derivative Works in Source or Object form.
3. Grant of Patent License. Subject to the terms and conditions of
this License, each Contributor hereby grants to You a perpetual,
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
(except as stated in this section) patent license to make, have made,
use, offer to sell, sell, import, and otherwise transfer the Work,
where such license applies only to those patent claims licensable
by such Contributor that are necessarily infringed by their
Contribution(s) alone or by combination of their Contribution(s)
with the Work to which such Contribution(s) was submitted. If You
institute patent litigation against any entity (including a
cross-claim or counterclaim in a lawsuit) alleging that the Work
or a Contribution incorporated within the Work constitutes direct
or contributory patent infringement, then any patent licenses
granted to You under this License for that Work shall terminate
as of the date such litigation is filed.
4. Redistribution. You may reproduce and distribute copies of the
Work or Derivative Works thereof in any medium, with or without
modifications, and in Source or Object form, provided that You
meet the following conditions:
(a) You must give any other recipients of the Work or
Derivative Works a copy of this License; and
(b) You must cause any modified files to carry prominent notices
stating that You changed the files; and
(c) You must retain, in the Source form of any Derivative Works
that You distribute, all copyright, patent, trademark, and
attribution notices from the Source form of the Work,
excluding those notices that do not pertain to any part of
the Derivative Works; and
(d) If the Work includes a "NOTICE" text file as part of its
distribution, then any Derivative Works that You distribute must
include a readable copy of the attribution notices contained
within such NOTICE file, excluding those notices that do not
pertain to any part of the Derivative Works, in at least one
of the following places: within a NOTICE text file distributed
as part of the Derivative Works; within the Source form or
documentation, if provided along with the Derivative Works; or,
within a display generated by the Derivative Works, if and
wherever such third-party notices normally appear. The contents
of the NOTICE file are for informational purposes only and
do not modify the License. You may add Your own attribution
notices within Derivative Works that You distribute, alongside
or as an addendum to the NOTICE text from the Work, provided
that such additional attribution notices cannot be construed
as modifying the License.
You may add Your own copyright statement to Your modifications and
may provide additional or different license terms and conditions
for use, reproduction, or distribution of Your modifications, or
for any such Derivative Works as a whole, provided Your use,
reproduction, and distribution of the Work otherwise complies with
the conditions stated in this License.
5. Submission of Contributions. Unless You explicitly state otherwise,
any Contribution intentionally submitted for inclusion in the Work
by You to the Licensor shall be under the terms and conditions of
this License, without any additional terms or conditions.
Notwithstanding the above, nothing herein shall supersede or modify
the terms of any separate license agreement you may have executed
with Licensor regarding such Contributions.
6. Trademarks. This License does not grant permission to use the trade
names, trademarks, service marks, or product names of the Licensor,
except as required for reasonable and customary use in describing the
origin of the Work and reproducing the content of the NOTICE file.
7. Disclaimer of Warranty. Unless required by applicable law or
agreed to in writing, Licensor provides the Work (and each
Contributor provides its Contributions) on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
implied, including, without limitation, any warranties or conditions
of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
PARTICULAR PURPOSE. You are solely responsible for determining the
appropriateness of using or redistributing the Work and assume any
risks associated with Your exercise of permissions under this License.
8. Limitation of Liability. In no event and under no legal theory,
whether in tort (including negligence), contract, or otherwise,
unless required by applicable law (such as deliberate and grossly
negligent acts) or agreed to in writing, shall any Contributor be
liable to You for damages, including any direct, indirect, special,
incidental, or consequential damages of any character arising as a
result of this License or out of the use or inability to use the
Work (including but not limited to damages for loss of goodwill,
work stoppage, computer failure or malfunction, or any and all
other commercial damages or losses), even if such Contributor
has been advised of the possibility of such damages.
9. Accepting Warranty or Additional Liability. While redistributing
the Work or Derivative Works thereof, You may choose to offer,
and charge a fee for, acceptance of support, warranty, indemnity,
or other liability obligations and/or rights consistent with this
License. However, in accepting such obligations, You may act only
on Your own behalf and on Your sole responsibility, not on behalf
of any other Contributor, and only if You agree to indemnify,
defend, and hold each Contributor harmless for any liability
incurred by, or claims asserted against, such Contributor by reason
of your accepting any such warranty or additional liability.
END OF TERMS AND CONDITIONS
linebender-resvg-fd841e1/crates/c-api/LICENSE-MIT 0000664 0000000 0000000 00000002041 15000020642 0021253 0 ustar 00root root 0000000 0000000 Copyright 2017 the Resvg Authors
Permission is hereby granted, free of charge, to any
person obtaining a copy of this software and associated
documentation files (the "Software"), to deal in the
Software without restriction, including without
limitation the rights to use, copy, modify, merge,
publish, distribute, sublicense, and/or sell copies of
the Software, and to permit persons to whom the Software
is furnished to do so, subject to the following
conditions:
The above copyright notice and this permission notice
shall be included in all copies or substantial portions
of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF
ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED
TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A
PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT
SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR
IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
DEALINGS IN THE SOFTWARE.
linebender-resvg-fd841e1/crates/c-api/README.md 0000664 0000000 0000000 00000001650 15000020642 0021103 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.
## License
Licensed under either of
- Apache License, Version 2.0 ([LICENSE-APACHE](LICENSE-APACHE) or )
- MIT license ([LICENSE-MIT](LICENSE-MIT) or )
at your option.
## Contribution
Contributions are welcome by pull request.
The [Rust code of conduct] applies.
Unless you explicitly state otherwise, any contribution intentionally submitted for inclusion in the work by you, as defined in the Apache-2.0 license, shall be licensed as above, without any additional terms or conditions.
[Rust Code of Conduct]: https://www.rust-lang.org/policies/code-of-conduct
linebender-resvg-fd841e1/crates/c-api/ResvgQt.h 0000664 0000000 0000000 00000032734 15000020642 0021377 0 ustar 00root root 0000000 0000000 // Copyright 2018 the Resvg Authors
// SPDX-License-Identifier: Apache-2.0 OR MIT
/**
* @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 45
#define RESVG_QT_PATCH_VERSION 1
#define RESVG_QT_VERSION "0.45.1"
#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/linebender/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
linebender-resvg-fd841e1/crates/c-api/cbindgen.toml 0000664 0000000 0000000 00000001061 15000020642 0022266 0 ustar 00root root 0000000 0000000 language = "C"
include_guard = "RESVG_H"
braces = "SameLine"
tab_width = 4
documentation_style = "doxy"
header = """// Copyright 2021 the Resvg Authors
// SPDX-License-Identifier: Apache-2.0 OR MIT
/**
* @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",
]
linebender-resvg-fd841e1/crates/c-api/examples/ 0000775 0000000 0000000 00000000000 15000020642 0021440 5 ustar 00root root 0000000 0000000 linebender-resvg-fd841e1/crates/c-api/examples/cairo/ 0000775 0000000 0000000 00000000000 15000020642 0022535 5 ustar 00root root 0000000 0000000 linebender-resvg-fd841e1/crates/c-api/examples/cairo/Makefile 0000664 0000000 0000000 00000000660 15000020642 0024177 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)
linebender-resvg-fd841e1/crates/c-api/examples/cairo/README.md 0000664 0000000 0000000 00000000351 15000020642 0024013 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
```
linebender-resvg-fd841e1/crates/c-api/examples/cairo/example.c 0000664 0000000 0000000 00000003621 15000020642 0024336 0 ustar 00root root 0000000 0000000 // Copyright 2020 the Resvg Authors
// SPDX-License-Identifier: Apache-2.0 OR MIT
#include
#include
#include
#include
#include
int main(int argc, char **argv)
{
if (argc != 3)
{
printf("Usage:\n\texample in.svg out.png");
abort();
}
// Initialize resvg's library logging system
resvg_init_log();
resvg_options *opt = resvg_options_create();
resvg_options_load_system_fonts(opt);
// Optionally, you can add some CSS to control the SVG rendering.
resvg_options_set_stylesheet(opt, "svg { fill: black; }");
resvg_render_tree *tree;
// Construct a tree from the svg file and pass in some options
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;
// Using the dimension info, allocate enough pixels to account for the entire image
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;
}
// Save image
cairo_surface_write_to_png(surface, argv[2]);
// De-initialize the allocated memory
cairo_surface_destroy(surface);
resvg_tree_destroy(tree);
return 0;
}
linebender-resvg-fd841e1/crates/c-api/lib.rs 0000664 0000000 0000000 00000063626 15000020642 0020753 0 ustar 00root root 0000000 0000000 // Copyright 2020 the Resvg Authors
// SPDX-License-Identifier: Apache-2.0 OR MIT
//! 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;
}
/// @brief Provides the content of a stylesheet that will be used when resolving CSS attributes.
///
/// Must be UTF-8. Can be set to NULL.
///
/// Default: NULL
#[no_mangle]
pub extern "C" fn resvg_options_set_stylesheet(opt: *mut resvg_options, content: *const c_char) {
if content.is_null() {
cast_opt(opt).style_sheet = None;
} else {
cast_opt(opt).style_sheet = Some(cstr_to_str(content).unwrap().into());
}
}
/// @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) {}
}
linebender-resvg-fd841e1/crates/c-api/resvg.h 0000664 0000000 0000000 00000033170 15000020642 0021125 0 ustar 00root root 0000000 0000000 // Copyright 2021 the Resvg Authors
// SPDX-License-Identifier: Apache-2.0 OR MIT
/**
* @file resvg.h
*
* resvg C API
*/
#ifndef RESVG_H
#define RESVG_H
#include
#include
#define RESVG_MAJOR_VERSION 0
#define RESVG_MINOR_VERSION 45
#define RESVG_PATCH_VERSION 1
#define RESVG_VERSION "0.45.1"
/**
* @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 Provides the content of a stylesheet that will be used when resolving CSS attributes.
*
* Must be UTF-8. Can be set to NULL.
*
* Default: NULL
*/
void resvg_options_set_stylesheet(resvg_options *opt, const char *content);
/**
* @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 */
linebender-resvg-fd841e1/crates/resvg/ 0000775 0000000 0000000 00000000000 15000020642 0017757 5 ustar 00root root 0000000 0000000 linebender-resvg-fd841e1/crates/resvg/Cargo.toml 0000664 0000000 0000000 00000002511 15000020642 0021706 0 ustar 00root root 0000000 0000000 [package]
name = "resvg"
version = "0.45.1"
keywords = ["svg", "render", "raster"]
license.workspace = true
edition = "2021"
rust-version = "1.67.1"
description = "An SVG rendering library."
repository = "https://github.com/linebender/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.2.0", optional = true }
log = "0.4"
pico-args = { version = "0.5", features = ["eq-separator"] }
rgb = "0.8"
svgtypes = "0.15.3"
tiny-skia = "0.11.4"
usvg = { path = "../usvg", version = "0.45.1", 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"]
linebender-resvg-fd841e1/crates/resvg/LICENSE-APACHE 0000664 0000000 0000000 00000023675 15000020642 0021720 0 ustar 00root root 0000000 0000000 Apache License
Version 2.0, January 2004
http://www.apache.org/licenses/
TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
1. Definitions.
"License" shall mean the terms and conditions for use, reproduction,
and distribution as defined by Sections 1 through 9 of this document.
"Licensor" shall mean the copyright owner or entity authorized by
the copyright owner that is granting the License.
"Legal Entity" shall mean the union of the acting entity and all
other entities that control, are controlled by, or are under common
control with that entity. For the purposes of this definition,
"control" means (i) the power, direct or indirect, to cause the
direction or management of such entity, whether by contract or
otherwise, or (ii) ownership of fifty percent (50%) or more of the
outstanding shares, or (iii) beneficial ownership of such entity.
"You" (or "Your") shall mean an individual or Legal Entity
exercising permissions granted by this License.
"Source" form shall mean the preferred form for making modifications,
including but not limited to software source code, documentation
source, and configuration files.
"Object" form shall mean any form resulting from mechanical
transformation or translation of a Source form, including but
not limited to compiled object code, generated documentation,
and conversions to other media types.
"Work" shall mean the work of authorship, whether in Source or
Object form, made available under the License, as indicated by a
copyright notice that is included in or attached to the work
(an example is provided in the Appendix below).
"Derivative Works" shall mean any work, whether in Source or Object
form, that is based on (or derived from) the Work and for which the
editorial revisions, annotations, elaborations, or other modifications
represent, as a whole, an original work of authorship. For the purposes
of this License, Derivative Works shall not include works that remain
separable from, or merely link (or bind by name) to the interfaces of,
the Work and Derivative Works thereof.
"Contribution" shall mean any work of authorship, including
the original version of the Work and any modifications or additions
to that Work or Derivative Works thereof, that is intentionally
submitted to Licensor for inclusion in the Work by the copyright owner
or by an individual or Legal Entity authorized to submit on behalf of
the copyright owner. For the purposes of this definition, "submitted"
means any form of electronic, verbal, or written communication sent
to the Licensor or its representatives, including but not limited to
communication on electronic mailing lists, source code control systems,
and issue tracking systems that are managed by, or on behalf of, the
Licensor for the purpose of discussing and improving the Work, but
excluding communication that is conspicuously marked or otherwise
designated in writing by the copyright owner as "Not a Contribution."
"Contributor" shall mean Licensor and any individual or Legal Entity
on behalf of whom a Contribution has been received by Licensor and
subsequently incorporated within the Work.
2. Grant of Copyright License. Subject to the terms and conditions of
this License, each Contributor hereby grants to You a perpetual,
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
copyright license to reproduce, prepare Derivative Works of,
publicly display, publicly perform, sublicense, and distribute the
Work and such Derivative Works in Source or Object form.
3. Grant of Patent License. Subject to the terms and conditions of
this License, each Contributor hereby grants to You a perpetual,
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
(except as stated in this section) patent license to make, have made,
use, offer to sell, sell, import, and otherwise transfer the Work,
where such license applies only to those patent claims licensable
by such Contributor that are necessarily infringed by their
Contribution(s) alone or by combination of their Contribution(s)
with the Work to which such Contribution(s) was submitted. If You
institute patent litigation against any entity (including a
cross-claim or counterclaim in a lawsuit) alleging that the Work
or a Contribution incorporated within the Work constitutes direct
or contributory patent infringement, then any patent licenses
granted to You under this License for that Work shall terminate
as of the date such litigation is filed.
4. Redistribution. You may reproduce and distribute copies of the
Work or Derivative Works thereof in any medium, with or without
modifications, and in Source or Object form, provided that You
meet the following conditions:
(a) You must give any other recipients of the Work or
Derivative Works a copy of this License; and
(b) You must cause any modified files to carry prominent notices
stating that You changed the files; and
(c) You must retain, in the Source form of any Derivative Works
that You distribute, all copyright, patent, trademark, and
attribution notices from the Source form of the Work,
excluding those notices that do not pertain to any part of
the Derivative Works; and
(d) If the Work includes a "NOTICE" text file as part of its
distribution, then any Derivative Works that You distribute must
include a readable copy of the attribution notices contained
within such NOTICE file, excluding those notices that do not
pertain to any part of the Derivative Works, in at least one
of the following places: within a NOTICE text file distributed
as part of the Derivative Works; within the Source form or
documentation, if provided along with the Derivative Works; or,
within a display generated by the Derivative Works, if and
wherever such third-party notices normally appear. The contents
of the NOTICE file are for informational purposes only and
do not modify the License. You may add Your own attribution
notices within Derivative Works that You distribute, alongside
or as an addendum to the NOTICE text from the Work, provided
that such additional attribution notices cannot be construed
as modifying the License.
You may add Your own copyright statement to Your modifications and
may provide additional or different license terms and conditions
for use, reproduction, or distribution of Your modifications, or
for any such Derivative Works as a whole, provided Your use,
reproduction, and distribution of the Work otherwise complies with
the conditions stated in this License.
5. Submission of Contributions. Unless You explicitly state otherwise,
any Contribution intentionally submitted for inclusion in the Work
by You to the Licensor shall be under the terms and conditions of
this License, without any additional terms or conditions.
Notwithstanding the above, nothing herein shall supersede or modify
the terms of any separate license agreement you may have executed
with Licensor regarding such Contributions.
6. Trademarks. This License does not grant permission to use the trade
names, trademarks, service marks, or product names of the Licensor,
except as required for reasonable and customary use in describing the
origin of the Work and reproducing the content of the NOTICE file.
7. Disclaimer of Warranty. Unless required by applicable law or
agreed to in writing, Licensor provides the Work (and each
Contributor provides its Contributions) on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
implied, including, without limitation, any warranties or conditions
of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
PARTICULAR PURPOSE. You are solely responsible for determining the
appropriateness of using or redistributing the Work and assume any
risks associated with Your exercise of permissions under this License.
8. Limitation of Liability. In no event and under no legal theory,
whether in tort (including negligence), contract, or otherwise,
unless required by applicable law (such as deliberate and grossly
negligent acts) or agreed to in writing, shall any Contributor be
liable to You for damages, including any direct, indirect, special,
incidental, or consequential damages of any character arising as a
result of this License or out of the use or inability to use the
Work (including but not limited to damages for loss of goodwill,
work stoppage, computer failure or malfunction, or any and all
other commercial damages or losses), even if such Contributor
has been advised of the possibility of such damages.
9. Accepting Warranty or Additional Liability. While redistributing
the Work or Derivative Works thereof, You may choose to offer,
and charge a fee for, acceptance of support, warranty, indemnity,
or other liability obligations and/or rights consistent with this
License. However, in accepting such obligations, You may act only
on Your own behalf and on Your sole responsibility, not on behalf
of any other Contributor, and only if You agree to indemnify,
defend, and hold each Contributor harmless for any liability
incurred by, or claims asserted against, such Contributor by reason
of your accepting any such warranty or additional liability.
END OF TERMS AND CONDITIONS
linebender-resvg-fd841e1/crates/resvg/LICENSE-MIT 0000664 0000000 0000000 00000002041 15000020642 0021410 0 ustar 00root root 0000000 0000000 Copyright 2017 the Resvg Authors
Permission is hereby granted, free of charge, to any
person obtaining a copy of this software and associated
documentation files (the "Software"), to deal in the
Software without restriction, including without
limitation the rights to use, copy, modify, merge,
publish, distribute, sublicense, and/or sell copies of
the Software, and to permit persons to whom the Software
is furnished to do so, subject to the following
conditions:
The above copyright notice and this permission notice
shall be included in all copies or substantial portions
of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF
ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED
TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A
PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT
SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR
IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
DEALINGS IN THE SOFTWARE.
linebender-resvg-fd841e1/crates/resvg/README.md 0000777 0000000 0000000 00000000000 15000020642 0023136 2../../README.md ustar 00root root 0000000 0000000 linebender-resvg-fd841e1/crates/resvg/examples/ 0000775 0000000 0000000 00000000000 15000020642 0021575 5 ustar 00root root 0000000 0000000 linebender-resvg-fd841e1/crates/resvg/examples/bboxes.svg 0000664 0000000 0000000 00000005774 15000020642 0023615 0 ustar 00root root 0000000 0000000
linebender-resvg-fd841e1/crates/resvg/examples/custom_href_resolver.rs 0000664 0000000 0000000 00000002467 15000020642 0026413 0 ustar 00root root 0000000 0000000 // Copyright 2022 the Resvg Authors
// SPDX-License-Identifier: Apache-2.0 OR MIT
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();
}
linebender-resvg-fd841e1/crates/resvg/examples/custom_href_resolver.svg 0000664 0000000 0000000 00000000413 15000020642 0026553 0 ustar 00root root 0000000 0000000
linebender-resvg-fd841e1/crates/resvg/examples/draw_bboxes.rs 0000664 0000000 0000000 00000005011 15000020642 0024437 0 ustar 00root root 0000000 0000000 // Copyright 2017 the Resvg Authors
// SPDX-License-Identifier: Apache-2.0 OR MIT
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 {
// Get file's absolute directory.
resources_dir: std::fs::canonicalize(&args[1])
.ok()
.and_then(|p| p.parent().map(|p| p.to_path_buf())),
..usvg::Options::default()
};
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 stroke = tiny_skia::Stroke {
width: 1.0 / zoom, // prevent stroke scaling as well
..tiny_skia::Stroke::default()
};
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);
}
}
}
linebender-resvg-fd841e1/crates/resvg/examples/ferris.png 0000664 0000000 0000000 00000102110 15000020642 0023570 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