Skip to content

[vector_graphics_compiler] The initial stroke-width is not scaled by transforms #196088

Closed
flutter/packages
#13577

Description

@saitatter

Steps to reproduce

  1. Compile an SVG with a stroke that has no stroke-width, under a transform that scales it.
  2. Render it with VectorGraphic, or SvgPicture from flutter_svg.
  3. Compare it with a browser, or with the same shape using an explicit stroke-width="1".
<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 100 60">
  <path d="M0 0H20" stroke="#26c" transform="translate(10 15) scale(4)"/>
  <path d="M0 0H20" stroke="#26c" stroke-width="1" transform="translate(10 40) scale(4)"/>
</svg>

Expected results

The initial value of stroke-width is 1, so both lines are the same width (4 after the transform).

Actual results

The line without stroke-width stays 1 wide, and only the explicit one is scaled. Scaling down has the same problem: the initial width stays 1 under scale(0.25).

The compiled paints show it:

Stroke(color: Color(0xff2266cc))             // no stroke-width
Stroke(color: Color(0xff2266cc), width: 4.0) // stroke-width="1"

Cause

AffineMatrix.scaleStrokeWidth returns null when the width is null, so the initial width is never scaled:

https://github.com/flutter/packages/blob/63881f9b11/packages/vector_graphics_compiler/lib/src/geometry/matrix.dart#L48-L57

A scale from width and height on the root <svg> is not affected, because it is applied at runtime. The ghostscriptTiger test asset does hit this: it has strokes without a width under matrix(1.7656463 ...), and ghostScriptTigerPaints currently expects those strokes to have no width.

Screenshots

Compared with Chrome 156. Left: encodeSvg and VectorGraphic. Right: Chrome.

Comparison with Chrome

Flutter version

Reproduced with vector_graphics_compiler at 63881f9 (1.3.4), in flutter test on Windows 11.

Flutter 3.47.7 • channel stable
Framework • revision abaf9c5237
Tools • Dart 3.13.5

Activity

  1. added
    in triage
    on Nov 6, 2026
  2. saurabh-mirajkar commented on Nov 6, 2026

    @saurabh-mirajkar
    Contributor

    @saitatter Thanks for the report. Labelling for team-engine to investigate further.

  3. added
    package
    team-engine
    p: vector_graphics
    and removed
    in triage
    on Nov 6, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    p: vector_graphicspackageteam-engine

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions