Repository: linebender/resvg (language: rust)

Issue:
No text in referenced SVGs
We should convert text to paths in referenced SVGs as well.


Discussion / hints:

Fix patch:
diff --git a/crates/usvg-text-layout/src/lib.rs b/crates/usvg-text-layout/src/lib.rs
index 5c194965e..680e4d929 100644
--- a/crates/usvg-text-layout/src/lib.rs
+++ b/crates/usvg-text-layout/src/lib.rs
@@ -84,6 +84,12 @@ fn convert_text(root: Node, fontdb: &fontdb::Database) {
             text_nodes.push(node.clone());
         }
 
+        if let NodeKind::Image(ref mut image) = *node.borrow_mut() {
+            if let ImageKind::SVG(ref mut tree) = image.kind {
+                tree.convert_text(fontdb);
+            }
+        }
+
         node.subroots(|subroot| convert_text(subroot, fontdb))
     }
 
diff --git a/crates/usvg-tree/src/lib.rs b/crates/usvg-tree/src/lib.rs
index d162e4980..0dce28507 100644
--- a/crates/usvg-tree/src/lib.rs
+++ b/crates/usvg-tree/src/lib.rs
@@ -1027,6 +1027,15 @@ fn has_text_nodes(root: &Node) -> bool {
         }
 
         let mut has_text = false;
+
+        if let NodeKind::Image(ref image) = *node.borrow() {
+            if let ImageKind::SVG(ref tree) = image.kind {
+                if has_text_nodes(&tree.root) {
+                    has_text = true;
+                }
+            }
+        }
+
         node.subroots(|subroot| {
             if has_text_nodes(&subroot) {
                 has_text = true;
@@ -1290,7 +1299,7 @@ fn calc_node_bbox(node: &Node, ts: Transform) -> Option<BBox> {
             for child in node.children() {
                 let child_transform = if let NodeKind::Group(ref group) = *child.borrow() {
                     ts.pre_concat(group.transform)
-                }   else {
+                } else {
                     ts
                 };
                 if let Some(c_bbox) = calc_node_bbox(&child, child_transform) {


Test patch:
diff --git a/crates/resvg/tests/tests/structure/image/embedded-svg-with-text.png b/crates/resvg/tests/tests/structure/image/embedded-svg-with-text.png
new file mode 100644
index 000000000..d34a8fdee
Binary files /dev/null and b/crates/resvg/tests/tests/structure/image/embedded-svg-with-text.png differ
diff --git a/crates/resvg/tests/tests/structure/image/embedded-svg-with-text.svg b/crates/resvg/tests/tests/structure/image/embedded-svg-with-text.svg
new file mode 100644
index 000000000..ac25291b7
--- /dev/null
+++ b/crates/resvg/tests/tests/structure/image/embedded-svg-with-text.svg
@@ -0,0 +1,8 @@
+<svg id="svg1" viewBox="0 0 80 80" xmlns="http://www.w3.org/2000/svg"
+     xmlns:xlink="http://www.w3.org/1999/xlink">
+    <title>Embedded SVG with text</title>
+
+    <image id="image1" x="8" y="8" width="64" height="64" xlink:href="data:image/svg+xml;base64,PHN2ZyBpZD0ic3ZnMSIgdmlld0JveD0iMCAwIDIwMCAyMDAiIHhtbG5zPSJodHRwOi8vd3d3LnczLm9yZy8yMDAwL3N2ZyIKICAgICBmb250LWZhbWlseT0iTm90byBTYW5zIiBmb250LXNpemU9IjY0Ij4KICAgIDx0aXRsZT5TaW1wbGUgY2FzZTwvdGl0bGU+CgogICAgPHBhdGggaWQ9ImNyb3NzaGFpciIgZD0iTSAyMCAxMDAgTCAxODAgMTAwIE0gMTAwIDIwIEwgMTAwIDE4MCIKICAgICAgICAgIHN0cm9rZT0iZ3JheSIgc3Ryb2tlLXdpZHRoPSIwLjUiLz4KCiAgICA8dGV4dCBpZD0idGV4dDEiIHg9IjMyIiB5PSIxMDAiPlRleHQ8L3RleHQ+CgogICAgPCEtLSBpbWFnZSBmcmFtZSAtLT4KICAgIDxyZWN0IGlkPSJmcmFtZSIgeD0iMSIgeT0iMSIgd2lkdGg9IjE5OCIgaGVpZ2h0PSIxOTgiIGZpbGw9Im5vbmUiIHN0cm9rZT0iYmxhY2siLz4KPC9zdmc+Cg=="/>
+
+    <rect id="frame" x="1" y="1" width="78" height="78" fill="none" stroke="black"/>
+</svg>