summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--Cargo.toml3
-rw-r--r--capi/src/lib.rs1
-rw-r--r--src/backend_utils/image.rs1
-rw-r--r--tools/rendersvg/src/args.rs2
-rw-r--r--tools/usvg/src/main.rs5
-rw-r--r--usvg/CHANGELOG.md2
-rw-r--r--usvg/Cargo.toml4
-rw-r--r--usvg/src/convert/clippath.rs4
-rw-r--r--usvg/src/convert/mod.rs4
-rw-r--r--usvg/src/convert/path.rs9
-rw-r--r--usvg/src/options.rs4
-rw-r--r--usvg/testing_tools/cache.csv14
12 files changed, 20 insertions, 33 deletions
diff --git a/Cargo.toml b/Cargo.toml
index d696a9e..70238f9 100644
--- a/Cargo.toml
+++ b/Cargo.toml
@@ -30,8 +30,7 @@ travis-ci = { repository = "RazrFalcon/resvg" }
[dependencies]
log = "0.4.5"
rgb = "0.8.9"
-#usvg = { git = "https://github.com/RazrFalcon/usvg", rev = "5346684" }
-usvg = { path = "./usvg" }
+usvg = { path = "usvg" }
unicode-segmentation = "1.2.1"
# cairo backend
diff --git a/capi/src/lib.rs b/capi/src/lib.rs
index 0ad1fb3..0a80fab 100644
--- a/capi/src/lib.rs
+++ b/capi/src/lib.rs
@@ -708,7 +708,6 @@ fn to_native_opt(opt: &resvg_options) -> resvg::Options {
font_size: opt.font_size,
languages,
keep_named_groups: opt.keep_named_groups,
- keep_invisible_shapes: false,
},
fit_to,
background,
diff --git a/src/backend_utils/image.rs b/src/backend_utils/image.rs
index 9939cde..68d5d67 100644
--- a/src/backend_utils/image.rs
+++ b/src/backend_utils/image.rs
@@ -28,7 +28,6 @@ pub fn load_sub_svg(
font_size: opt.usvg.font_size,
languages: opt.usvg.languages.clone(),
keep_named_groups: false,
- keep_invisible_shapes: false,
},
fit_to: FitTo::Original,
background: None,
diff --git a/tools/rendersvg/src/args.rs b/tools/rendersvg/src/args.rs
index e313a2b..663c3b2 100644
--- a/tools/rendersvg/src/args.rs
+++ b/tools/rendersvg/src/args.rs
@@ -242,7 +242,6 @@ pub fn parse() -> Result<(Args, Options), String> {
// We don't have to keep named groups when we don't need them
// because it will slow down rendering.
let keep_named_groups = app_args.query_all || app_args.export_id.is_some();
- let keep_invisible_shapes = keep_named_groups;
let mut fit_to = FitTo::Original;
if let Some(w) = args.width {
@@ -266,7 +265,6 @@ pub fn parse() -> Result<(Args, Options), String> {
font_size: args.font_size as f64,
languages,
keep_named_groups,
- keep_invisible_shapes,
},
fit_to,
background: args.background,
diff --git a/tools/usvg/src/main.rs b/tools/usvg/src/main.rs
index 746e901..c2272ab 100644
--- a/tools/usvg/src/main.rs
+++ b/tools/usvg/src/main.rs
@@ -92,9 +92,6 @@ struct Args {
#[options(no_short)]
keep_named_groups: bool,
- #[options(no_short)]
- keep_invisible_shapes: bool,
-
#[options(no_short, meta = "DPI", default = "96", parse(try_from_str = "parse_dpi"))]
dpi: u32,
@@ -165,7 +162,6 @@ OPTIONS:
-V, --version Prints version information
-c Prints the output SVG to the stdout
--keep-named-groups Disables removing of groups with non-empty ID
- --keep-invisible-shapes Disables removing of invisible shapes
--dpi DPI Sets the resolution
[default: 96] [possible values: 10..4000]
--font-family FAMILY Sets the default font family
@@ -231,7 +227,6 @@ fn process(args: &Args) -> Result<(), String> {
font_size: args.font_size as f64,
languages,
keep_named_groups: args.keep_named_groups,
- keep_invisible_shapes: args.keep_invisible_shapes,
};
let input_str = match in_svg {
diff --git a/usvg/CHANGELOG.md b/usvg/CHANGELOG.md
index 5702b2c..74b21d6 100644
--- a/usvg/CHANGELOG.md
+++ b/usvg/CHANGELOG.md
@@ -8,9 +8,9 @@ and this project adheres to [Semantic Versioning](http://semver.org/).
### Added
- Implement `FuzzyEq` for `Rect`, `Size` and `Point`.
- `StrokeMiterlimit` and `FontSize` wrappers for `f64`.
-- `Options::keep_invisible_shapes` and `--keep-invisible-shapes` to CLI.
### Changed
+- Shapes without fill and stroke will no longer be removed.
- `FilterPrimitive::filter_input` was removed and each filter primitive that can
have an input has it's own `filter_input` field now.
- Rename `filter_input` fields into `input`.
diff --git a/usvg/Cargo.toml b/usvg/Cargo.toml
index 083137d..bf57420 100644
--- a/usvg/Cargo.toml
+++ b/usvg/Cargo.toml
@@ -1,8 +1,8 @@
[package]
name = "usvg"
-# When updating version, also modify html_root_url in the lib.rs and in the cli/Cargo.toml
+# When updating version, also modify html_root_url in the lib.rs and in the ../tools/Cargo.toml
version = "0.4.0"
-authors = ["Reizner Evgeniy <razrfalcon@gmail.com>"]
+authors = ["Evgeniy Reizner <razrfalcon@gmail.com>"]
keywords = ["svg"]
license = "MPL-2.0"
description = "An SVG simplification library."
diff --git a/usvg/src/convert/clippath.rs b/usvg/src/convert/clippath.rs
index 46a736c..cf639cd 100644
--- a/usvg/src/convert/clippath.rs
+++ b/usvg/src/convert/clippath.rs
@@ -54,13 +54,13 @@ pub fn convert_children(
| EId::Circle
| EId::Ellipse => {
if let Some(d) = shapes::convert(&node) {
- path::convert(&node, d, opt, parent.clone(), tree);
+ path::convert(&node, d, parent.clone(), tree);
}
}
EId::Path => {
let attrs = node.attributes();
if let Some(d) = attrs.get_path(AId::D) {
- path::convert(&node, d.clone(), opt, parent.clone(), tree);
+ path::convert(&node, d.clone(), parent.clone(), tree);
}
}
EId::Text => {
diff --git a/usvg/src/convert/mod.rs b/usvg/src/convert/mod.rs
index 9a55b9e..c37ba8e 100644
--- a/usvg/src/convert/mod.rs
+++ b/usvg/src/convert/mod.rs
@@ -297,7 +297,7 @@ pub(super) fn convert_nodes(
| EId::Circle
| EId::Ellipse => {
if let Some(d) = shapes::convert(&node) {
- path::convert(&node, d, opt, parent_node.clone(), tree);
+ path::convert(&node, d, parent_node.clone(), tree);
}
}
EId::Use
@@ -308,7 +308,7 @@ pub(super) fn convert_nodes(
EId::Path => {
let attrs = node.attributes();
if let Some(d) = attrs.get_path(AId::D) {
- path::convert(&node, d.clone(), opt, parent_node.clone(), tree);
+ path::convert(&node, d.clone(), parent_node.clone(), tree);
}
}
EId::Text => {
diff --git a/usvg/src/convert/path.rs b/usvg/src/convert/path.rs
index b95d636..6104db3 100644
--- a/usvg/src/convert/path.rs
+++ b/usvg/src/convert/path.rs
@@ -21,7 +21,6 @@ use super::{
pub fn convert(
node: &svgdom::Node,
d: svgdom::Path,
- opt: &Options,
mut parent: tree::Node,
tree: &mut tree::Tree,
) {
@@ -35,7 +34,7 @@ pub fn convert(
let fill = fill::convert(tree, &attrs, has_bbox);
let stroke = stroke::convert(tree, &attrs, has_bbox);
let transform = attrs.get_transform(AId::Transform).unwrap_or_default();
- let visibility = super::convert_visibility(&attrs);
+ let mut visibility = super::convert_visibility(&attrs);
// Shapes without a bbox cannot be filled,
// and if there is no stroke than there is nothing to render.
@@ -43,8 +42,10 @@ pub fn convert(
return;
}
- if fill.is_none() && stroke.is_none() && !opt.keep_invisible_shapes {
- return;
+ // If a path doesn't have a fill or a stroke than it's invisible.
+ // By setting `visibility` to `hidden` we are disabling the rendering of this path.
+ if fill.is_none() && stroke.is_none() {
+ visibility = tree::Visibility::Hidden
}
parent.append_kind(tree::NodeKind::Path(tree::Path {
diff --git a/usvg/src/options.rs b/usvg/src/options.rs
index 9bc7451..0cd4954 100644
--- a/usvg/src/options.rs
+++ b/usvg/src/options.rs
@@ -35,9 +35,6 @@ pub struct Options {
/// If set to `true`, all non-empty groups with `id` attribute will not
/// be removed.
pub keep_named_groups: bool,
-
- /// Keep invisible shapes.
- pub keep_invisible_shapes: bool,
}
impl Default for Options {
@@ -50,7 +47,6 @@ impl Default for Options {
font_size: 12.0,
languages: vec!["en".to_string()],
keep_named_groups: false,
- keep_invisible_shapes: false,
}
}
}
diff --git a/usvg/testing_tools/cache.csv b/usvg/testing_tools/cache.csv
index 7debd9c..6426e0c 100644
--- a/usvg/testing_tools/cache.csv
+++ b/usvg/testing_tools/cache.csv
@@ -32,7 +32,7 @@ a-fill-019,be988bd0
a-fill-020,1e33edff
a-fill-021,2f5b8c7a
a-fill-022,2f5b8c7a
-a-fill-023,25e7c8ad
+a-fill-023,4c34a5c8
a-fill-024,054eb5ef
a-fill-025,2f5b8c7a
a-fill-026,2f5b8c7a
@@ -45,8 +45,8 @@ a-fill-032,598b8021
a-fill-033,bde3fb92
a-fill-034,2f5b8c7a
a-fill-035,2f5b8c7a
-a-fill-036,25e7c8ad
-a-fill-037,25e7c8ad
+a-fill-036,cdb0324b
+a-fill-037,cdb0324b
a-fill-opacity-001,6cff4b30
a-fill-opacity-002,66b483b4
a-fill-opacity-003,f4c2cad3
@@ -121,8 +121,8 @@ a-stroke-001,bf7debb2
a-stroke-002,de030caa
a-stroke-003,a33ddb56
a-stroke-004,b440b861
-a-stroke-005,25e7c8ad
-a-stroke-006,25e7c8ad
+a-stroke-005,4c34a5c8
+a-stroke-006,cdb0324b
a-stroke-007,2d9e2b44
a-stroke-008,e23eabf0
a-stroke-009,09f9cf6b
@@ -173,8 +173,8 @@ a-stroke-opacity-005,c7d01ace
a-stroke-opacity-006,8d6920af
a-stroke-width-001,fea02548
a-stroke-width-002,24f7fb57
-a-stroke-width-003,25e7c8ad
-a-stroke-width-004,25e7c8ad
+a-stroke-width-003,056dd467
+a-stroke-width-004,056dd467
a-stroke-width-005,ee0764c4
a-style-001,2f5b8c7a
a-style-002,2f5b8c7a