fix(export): outline SVG text for AI export
Build, Push and Deploy / build (push) Successful in 12s
Build, Push and Deploy / deploy (push) Successful in 25s

This commit is contained in:
lai_hong
2026-09-13 15:55:46 +08:00
parent cc5c3f9751
commit 1f9eb2853c
5 changed files with 147 additions and 6 deletions
+27
View File
@@ -0,0 +1,27 @@
from __future__ import annotations
import sys
from pathlib import Path
from xml.etree import ElementTree as ET
BACKEND_DIR = Path(__file__).resolve().parents[1]
if str(BACKEND_DIR) not in sys.path:
sys.path.insert(0, str(BACKEND_DIR))
from service import app as service_app # noqa: E402
def test_ai_export_outlines_chinese_svg_text() -> None:
source = b'''<svg xmlns="http://www.w3.org/2000/svg" width="300" height="100">
<text x="12" y="56" font-size="42" fill="#112233" transform="rotate(2 0 0)">你好 AI</text>
</svg>'''
outlined = service_app._outline_svg_text(source)
root = ET.fromstring(outlined)
names = [element.tag.rsplit("}", 1)[-1] for element in root.iter()]
assert "text" not in names
assert names.count("path") >= 3
assert b'rotate(2 0 0)' in outlined
assert b'fill="#112233"' in outlined