resvg
resvg copied to clipboard
Flattened Text Group always has the identity abs_transform
resvg version: 0.41
The group returned by Text::flattened always has the default abs_transform. usvg::text::flatten::flatten does not propagate the containing Text's abs_transform.
This does not affect resvg since resvg::render::render_group re-calculates abs_transform (Line 56).
https://github.com/RazrFalcon/resvg/blob/b908baf1a2b7bd724a7896f29bf56e2d666b87ff/crates/resvg/src/render.rs#L50-L61
All tests pass even after modifying usvg::text::flatten::flatten as follows.
if let Some(path) = span_builder.finish().and_then(|p| {
Path::new(
String::new(),
span.visibility,
span.fill.clone(),
span.stroke.clone(),
span.paint_order,
rendering_mode,
Arc::new(p),
+++ text.abs_transform,
--- Transform::default(),
)
}) {
stroke_bbox = stroke_bbox.expand(path.stroke_bounding_box());
new_paths.push(path);
}
if let Some(path) = span.line_through.as_ref() {
stroke_bbox = stroke_bbox.expand(path.data.bounds());
let mut path = path.clone();
path.rendering_mode = rendering_mode;
new_paths.push(path);
}
}
let mut group = Group {
id: text.id.clone(),
+++ abs_transform: text.abs_transform,
..Group::empty()
};
Is it intended to ~~re-calculate abs_transform in resvg and~~ keep abs_transform in Text::flattened default?
This is kinda intended. I will see what we can do about it.