diff --git a/src/shape/svg/svg_import.js b/src/shape/svg/svg_import.js
index b0ed21c138..f82eb09052 100644
--- a/src/shape/svg/svg_import.js
+++ b/src/shape/svg/svg_import.js
@@ -711,11 +711,20 @@ export function SVGImportAddon(p5, fn, lifecycles) {
);
this.tStack.current.scaleSelf(scaleX, scaleY);
} else {
- const scale = Math.min(w / vb.width, h / vb.height); // default: xMidYMid meet
+ const scale = Math.min(w / vb.width, h / vb.height);
+
+ // Default SVG alignment is xMidYMid meet.
+ const alignment = preserveAspectRatio?.trim().split(/\s+/)[0] || "xMidYMid";
+
+ const alignX = alignment.startsWith("xMin") ? 0
+ : alignment.startsWith("xMax") ? 1 : 0.5;
+
+ const alignY = alignment.endsWith("YMin") ? 0
+ : alignment.endsWith("YMax") ? 1 : 0.5;
this.tStack.current.translateSelf(
- (w - vb.width * scale) / 2 - vb.x * scale,
- (h - vb.height * scale) / 2 - vb.y * scale
+ (w - vb.width * scale) * alignX - vb.x * scale,
+ (h - vb.height * scale) * alignY - vb.y * scale
);
this.tStack.current.scaleSelf(scale, scale);
}
diff --git a/test/unit/assets/svg/defs-symbol-preserve-aspect-ratio-meet.svg b/test/unit/assets/svg/defs-symbol-preserve-aspect-ratio-meet.svg
new file mode 100644
index 0000000000..1fcc6fb932
--- /dev/null
+++ b/test/unit/assets/svg/defs-symbol-preserve-aspect-ratio-meet.svg
@@ -0,0 +1,27 @@
+
\ No newline at end of file
diff --git a/test/unit/svg/svg_import.js b/test/unit/svg/svg_import.js
index d4acf1d594..59cf8810a3 100644
--- a/test/unit/svg/svg_import.js
+++ b/test/unit/svg/svg_import.js
@@ -1151,6 +1151,95 @@ suite(' and