summaryrefslogtreecommitdiff
path: root/usvg/src
diff options
context:
space:
mode:
authorRazrFalcon <razrfalcon@gmail.com>2018-12-16 18:40:59 +0200
committerRazrFalcon <razrfalcon@gmail.com>2018-12-16 18:40:59 +0200
commit7058c08fd403f41b5d22136ebc1c428a355a9534 (patch)
tree953ec064faa9585ad3d841c0137a425b895c9056 /usvg/src
parent3b596797c5515e192b4a11912c8e3b26902228f9 (diff)
Shapes without fill and stroke will no longer be removed.
Diffstat (limited to 'usvg/src')
-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
4 files changed, 9 insertions, 12 deletions
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,
}
}
}