Commit b7329156 authored by RazrFalcon's avatar RazrFalcon

(usvg) Always export 'text-anchor', 'clip-path' and 'mask'.

parent c7cc598f
......@@ -16,6 +16,9 @@ and this project adheres to [Semantic Versioning](http://semver.org/).
### Changed
- Shapes without fill and stroke will no longer be removed.
- `clip-path`, `mask`, `filter` and `opacity` attributes will always be set on groups.
- `text-anchor` attribute will always be set on `tspan`.
- `clip-path` attribute will always be set on `clipPath`.
- `mask` attribute will always be set on `mask`.
- `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`.
......
......@@ -45,8 +45,7 @@ fn conv_defs(
defs: &mut svgdom::Node,
) {
let mut later_nodes = Vec::new();
let mut link_clip_later = Vec::new();
let mut link_mask_later = Vec::new();
let mut link_later = Vec::new();
for n in tree.defs().children() {
match *n.borrow() {
......@@ -85,8 +84,9 @@ fn conv_defs(
clip_elem.set_attribute((AId::ClipPathUnits, clip.units.to_string()));
conv_transform(AId::Transform, &clip.transform, &mut clip_elem);
if let Some(ref id) = clip.clip_path {
link_clip_later.push((id.clone(), clip_elem.clone()));
match clip.clip_path {
Some(ref id) => link_later.push((id.clone(), AId::ClipPath, clip_elem.clone())),
None => clip_elem.set_attribute((AId::ClipPath, AValue::None)),
}
later_nodes.push((n.clone(), clip_elem.clone()));
......@@ -100,8 +100,9 @@ fn conv_defs(
mask_elem.set_attribute((AId::MaskContentUnits, mask.content_units.to_string()));
conv_rect(mask.rect, &mut mask_elem);
if let Some(ref id) = mask.mask {
link_mask_later.push((id.clone(), mask_elem.clone()));
match mask.mask {
Some(ref id) => link_later.push((id.clone(), AId::Mask, mask_elem.clone())),
None => mask_elem.set_attribute((AId::Mask, AValue::None)),
}
later_nodes.push((n.clone(), mask_elem.clone()));
......@@ -273,12 +274,8 @@ fn conv_defs(
}
}
for (id, mut elem) in link_clip_later {
conv_link(tree, defs, AId::ClipPath, &id, &mut elem);
}
for (id, mut elem) in link_mask_later {
conv_link(tree, defs, AId::Mask, &id, &mut elem);
for (id, aid, mut elem) in link_later {
conv_link(tree, defs, aid, &id, &mut elem);
}
for (rnode, mut elem) in later_nodes {
......@@ -382,9 +379,7 @@ fn conv_elements(
chunk_tspan_elem.set_attribute((AId::Dy, dy.clone()));
}
if chunk.anchor != TextAnchor::Start {
chunk_tspan_elem.set_attribute((AId::TextAnchor, chunk.anchor.to_string()));
}
chunk_tspan_elem.set_attribute((AId::TextAnchor, chunk.anchor.to_string()));
for tspan in &chunk.spans {
let mut tspan_elem = new_doc.create_element(EId::Tspan);
......
......@@ -50,6 +50,12 @@ impl Opacity {
}
}
impl Default for Opacity {
fn default() -> Self {
Opacity::new(1.0)
}
}
wrap!(Opacity);
......
......@@ -169,3 +169,4 @@ e-tref-006,25,bug
e-tref-007,2005,chrome bug
e-tref-008,720,bug
e-tspan-015,3283,bug
e-tspan-018,280,chrome bug
This diff is collapsed.
......@@ -159,6 +159,7 @@ test!(group_clippath, false,
<defs>
<clipPath
id='clip1'
clip-path='none'
clipPathUnits='userSpaceOnUse'>
<path
fill='#000000'
......@@ -273,6 +274,7 @@ test!(pattern_without_children, false,
</svg>
");
// TODO: add mask, filter, marker
// All supported elements should be listed.
// We keep id's even if `keep_named_groups` is disabled.
// ID on `svg`, `defs`, `stop` and `tspan` is ignored because they can't be rendered
......@@ -351,6 +353,7 @@ test!(preserve_id, false,
</radialGradient>
<clipPath
id='clip1'
clip-path='none'
clipPathUnits='userSpaceOnUse'>
<path
id='rect2'
......@@ -420,7 +423,8 @@ test!(preserve_id, false,
visibility='visible'
d='M 10 20 L 30 40'/>
<text
id='text1'><tspan><tspan
id='text1'><tspan
text-anchor='start'><tspan
fill='#000000'
fill-opacity='1'
fill-rule='nonzero'
......@@ -436,7 +440,8 @@ test!(preserve_id, false,
visibility='visible'
word-spacing='normal'>Some text</tspan></tspan></text>
<text
id='text2'><tspan><tspan
id='text2'><tspan
text-anchor='start'><tspan
fill='#000000'
fill-opacity='1'
fill-rule='nonzero'
......
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