Fix bug where not all text nodes were detected (#2136)

This commit is contained in:
Laurenz Stampfl 2023-09-13 23:00:35 +02:00 committed by GitHub
parent c203eff9f4
commit 47c7975d70
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -15,7 +15,7 @@ use image::codecs::png::PngDecoder;
use image::io::Limits;
use image::{guess_format, ImageDecoder, ImageResult};
use typst_macros::{cast, Cast};
use usvg::{TreeParsing, TreeTextToPath};
use usvg::{NodeExt, TreeParsing, TreeTextToPath};
use crate::diag::{bail, format_xml_like_error, StrResult};
use crate::eval::Bytes;
@ -370,9 +370,9 @@ fn traverse_svg<F>(node: &usvg::Node, f: &mut F)
where
F: FnMut(&usvg::Node),
{
f(node);
for child in node.children() {
traverse_svg(&child, f);
for descendant in node.descendants() {
f(&descendant);
descendant.subroots(|subroot| traverse_svg(&subroot, f))
}
}