linebender / linebender/resvg

Flattened Text Group always has the identity abs_transform

Open
#733 1 comment 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Dominant language
Rust
Stars
4.1k
Forks
348
Avg merge
1d 14h
Merged PRs (30d)
3

Description

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?

Contributor guide

No contributing guide indexed for this repository

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start in usvg::text::flatten::flatten and compare its construction of flattened paths and groups with resvg::render::render_group, referenced in the issue. Run the existing test suite and add or update coverage for a Text with a non-default abs_transform; done means the intended transform is preserved consistently without changing existing rendering behavior.

Written by the indexing model from the issue text.

Assessment

Tech stack
rust
Domain
computer-graphics
Issue type
Bug
Difficulty
3/5
Estimated time
1-2 days
Activity status
Stale
Clarity
Clearly specified
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.