28 lines
866 B
Python
28 lines
866 B
Python
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
|