Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Flattened Text Group always has the identity abs_transform #733

Open
paxbun opened this issue Apr 8, 2024 · 1 comment
Open

Flattened Text Group always has the identity abs_transform #733

paxbun opened this issue Apr 8, 2024 · 1 comment

Comments

@paxbun
Copy link

paxbun commented Apr 8, 2024

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).

fn render_group(
group: &usvg::Group,
ctx: &Context,
transform: tiny_skia::Transform,
pixmap: &mut tiny_skia::PixmapMut,
) -> Option<()> {
let transform = transform.pre_concat(group.transform());
if !group.should_isolate() {
render_nodes(group, ctx, transform, pixmap);
return Some(());
}

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?

@paxbun paxbun changed the title Flattened Text Group always has the default abs_transform Flattened Text Group always has the identity abs_transform Apr 8, 2024
@RazrFalcon
Copy link
Owner

This is kinda intended. I will see what we can do about it.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants