summaryrefslogtreecommitdiff
path: root/src/text.rs
diff options
context:
space:
mode:
authorFederico Mena Quintero <federico@gnome.org>2020-11-04 19:40:26 -0600
committerFederico Mena Quintero <federico@gnome.org>2020-11-04 19:55:12 -0600
commit21b8bc12e717143a9c99c785f1877ce6ac25fe3c (patch)
tree7012f826e623902dee055a808aa81c2879f500d8 /src/text.rs
parent2ebd2ab1c9796e90d12d3c3a9cb9526488f47367 (diff)
downloadlibrsvg-21b8bc12e717143a9c99c785f1877ce6ac25fe3c.tar.gz
text: Don't create Spans for chars nodes that end up as empty strings after xml:space normalization
The new test fails without this commit; it creates inter-line spacings in the second <text> element.
Diffstat (limited to 'src/text.rs')
-rw-r--r--src/text.rs30
1 files changed, 17 insertions, 13 deletions
diff --git a/src/text.rs b/src/text.rs
index 9fc7ab7e..e94f2020 100644
--- a/src/text.rs
+++ b/src/text.rs
@@ -380,16 +380,20 @@ impl Chars {
dx: f64,
dy: f64,
depth: usize,
- ) -> Span {
+ ) -> Option<Span> {
self.ensure_normalized_string(node, values);
- Span::new(
- self.space_normalized.borrow().as_ref().unwrap(),
- values.clone(),
- dx,
- dy,
- depth,
- )
+ if self.space_normalized.borrow().as_ref().unwrap() == "" {
+ None
+ } else {
+ Some(Span::new(
+ self.space_normalized.borrow().as_ref().unwrap(),
+ values.clone(),
+ dx,
+ dy,
+ depth,
+ ))
+ }
}
fn to_chunks(
@@ -401,12 +405,12 @@ impl Chars {
dy: f64,
depth: usize,
) {
- let span = self.make_span(&node, values, dx, dy, depth);
-
- let num_chunks = chunks.len();
- assert!(num_chunks > 0);
+ if let Some(span) = self.make_span(&node, values, dx, dy, depth) {
+ let num_chunks = chunks.len();
+ assert!(num_chunks > 0);
- chunks[num_chunks - 1].spans.push(span);
+ chunks[num_chunks - 1].spans.push(span);
+ }
}
pub fn get_string(&self) -> String {