Commit 7058c08f authored by RazrFalcon's avatar RazrFalcon

Shapes without fill and stroke will no longer be removed.

parent 3b596797
......@@ -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
......
......@@ -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,
......
......@@ -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,
......
......@@ -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,
......
......@@ -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 {
......
......@@ -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`.
......
[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."
......
......@@ -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 => {
......
......@@ -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 => {
......
......@@ -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 {
......
......@@ -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,
}
}
}
......@@ -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
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment