From afb77ce60ac15f51925d6ab0ba0f0578199ded2b Mon Sep 17 00:00:00 2001 From: Jason Simmons Date: Thu, 14 Aug 2025 20:07:29 +0000 Subject: [PATCH 1/3] [vector_graphics_compiler] Set the m4_10 (Z scale) value to 1 when constructing an AffineMatrix from an SVG matrix The 4x4 matrix produced by the SVG matrix() function should have its 10th element set to 1. (see https://developer.mozilla.org/en-US/docs/Web/CSS/transform-function/matrix) The SVG matrix parser constructs an AffineMatrix from the SVG input. The AffineMatrix is then converted into a list that is given to Flutter engine APIs. Before https://github.com/flutter/engine/commit/62cb2c9ee7e88163344d38dd8e5ad3a260658d9f, the Flutter engine was implicitly overriding the 10th element of the matrix with a 1 value. After that commit, the engine uses the matrix contents as is and does not override any values. This PR changes the SVG matrix parser to explicitly set the AffineMatrix m4_10 parameter to 1. This reflects the SVG spec and produces output that matches the original engine behavior. See https://github.com/flutter/flutter/issues/171854 --- packages/vector_graphics_compiler/lib/src/svg/parsers.dart | 2 +- packages/vector_graphics_compiler/test/parsers_test.dart | 6 +++--- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/packages/vector_graphics_compiler/lib/src/svg/parsers.dart b/packages/vector_graphics_compiler/lib/src/svg/parsers.dart index 6dcba4b2be86..c3359759df8f 100644 --- a/packages/vector_graphics_compiler/lib/src/svg/parsers.dart +++ b/packages/vector_graphics_compiler/lib/src/svg/parsers.dart @@ -93,7 +93,7 @@ AffineMatrix _parseSvgMatrix(List params, AffineMatrix current) { final double e = params[4]; final double f = params[5]; - return AffineMatrix(a, b, c, d, e, f).multiplied(current); + return AffineMatrix(a, b, c, d, e, f, 1.0).multiplied(current); } AffineMatrix _parseSvgSkewX(List params, AffineMatrix current) { diff --git a/packages/vector_graphics_compiler/test/parsers_test.dart b/packages/vector_graphics_compiler/test/parsers_test.dart index 56c03891fe33..eeec94518e60 100644 --- a/packages/vector_graphics_compiler/test/parsers_test.dart +++ b/packages/vector_graphics_compiler/test/parsers_test.dart @@ -132,12 +132,12 @@ void main() { expect( parseTransform('matrix(1.5, 2.0, 3.0, 4.0, 5.0, 6.0)'), - const AffineMatrix(1.5, 2.0, 3.0, 4.0, 5.0, 6.0), + const AffineMatrix(1.5, 2.0, 3.0, 4.0, 5.0, 6.0, 1.0), ); expect( parseTransform('matrix(1.5, 2.0, 3.0, 4.0, 5.0, 6.0 )'), - const AffineMatrix(1.5, 2.0, 3.0, 4.0, 5.0, 6.0), + const AffineMatrix(1.5, 2.0, 3.0, 4.0, 5.0, 6.0, 1.0), ); expect( @@ -198,7 +198,7 @@ void main() { 0.70711, -0.70711, // 0.70711, 0.70711, // -640.89, 452.68, // - 0.70711, // + 1.0, // ), ); }); From 89e7a16e9a5436c0e0b627f1783bb3d953244f7a Mon Sep 17 00:00:00 2001 From: Jason Simmons Date: Thu, 14 Aug 2025 20:51:27 +0000 Subject: [PATCH 2/3] Update end-to-end test expectation --- packages/vector_graphics_compiler/test/end_to_end_test.dart | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/packages/vector_graphics_compiler/test/end_to_end_test.dart b/packages/vector_graphics_compiler/test/end_to_end_test.dart index 5f225a412a10..29a4ec2d58ac 100644 --- a/packages/vector_graphics_compiler/test/end_to_end_test.dart +++ b/packages/vector_graphics_compiler/test/end_to_end_test.dart @@ -320,7 +320,7 @@ void main() { 0.0, 0.0, 0.0, - 3.0, + 1.0, 0.0, 30.0, 40.0, From a9bda1f03fa1726d54b4ca482f3f5c11e03cac2c Mon Sep 17 00:00:00 2001 From: Jason Simmons Date: Thu, 14 Aug 2025 21:05:12 +0000 Subject: [PATCH 3/3] version and changelog --- packages/vector_graphics_compiler/CHANGELOG.md | 3 ++- packages/vector_graphics_compiler/pubspec.yaml | 2 +- 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/packages/vector_graphics_compiler/CHANGELOG.md b/packages/vector_graphics_compiler/CHANGELOG.md index 03eac0feb781..53d380682cc7 100644 --- a/packages/vector_graphics_compiler/CHANGELOG.md +++ b/packages/vector_graphics_compiler/CHANGELOG.md @@ -1,6 +1,7 @@ -## NEXT +## 1.1.18 * Updates minimum supported SDK version to Flutter 3.27/Dart 3.6. +* Fixes SVG matrix parsing to explicitly set the Z scale value. ## 1.1.17 diff --git a/packages/vector_graphics_compiler/pubspec.yaml b/packages/vector_graphics_compiler/pubspec.yaml index 7350a2e20bd2..85830ec40da4 100644 --- a/packages/vector_graphics_compiler/pubspec.yaml +++ b/packages/vector_graphics_compiler/pubspec.yaml @@ -2,7 +2,7 @@ name: vector_graphics_compiler description: A compiler to convert SVGs to the binary format used by `package:vector_graphics`. repository: https://github.com/flutter/packages/tree/main/packages/vector_graphics_compiler issue_tracker: https://github.com/flutter/flutter/issues?q=is%3Aissue+is%3Aopen+label%3A%22p%3A+vector_graphics%22 -version: 1.1.17 +version: 1.1.18 executables: vector_graphics_compiler: