summaryrefslogtreecommitdiff
path: root/svgio/qa/cppunit
diff options
context:
space:
mode:
authorHossein <hossein@libreoffice.org>2021-12-20 05:44:23 +0100
committerThorsten Behrens <thorsten.behrens@allotropia.de>2021-12-24 02:00:18 +0100
commit4e2e57b530544736804ab663f832173ba1d78559 (patch)
tree60904a5c37d20df21c8e785cda78e11aa2ce6967 /svgio/qa/cppunit
parentfbe169fa17adb832704ada89ae6d889ad31ae502 (diff)
tdf#97663 SVGIO: Fix line spacing for <tspan>
tdf#97663 is a regression caused by the commit 701324a1e1f7e0c181ff1a50956ced686785ea53. The previous patch caused LO to forget the size of the font which was needed to calculate line height based on em units. em, px, pt, cm, in... https://www.w3.org/Style/Examples/007/units.en.html Accompanied with this fix is a unit test provided to avoid this issue in the future. The fix can be tested with: make CPPUNIT_TEST_NAME="testTdf97663" -sr \ CppunitTest_svgio The em_units.svg is opened with Firefox, Chrome and Inkscape and the rendering in LibreOffice is compatible with the rendering in these applications. Change-Id: Idaecd9fb18101f7925fe2a917f7fc3fe7257ebc5 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/127130 Tested-by: Jenkins Reviewed-by: Thorsten Behrens <thorsten.behrens@allotropia.de>
Diffstat (limited to 'svgio/qa/cppunit')
-rw-r--r--svgio/qa/cppunit/SvgImportTest.cxx20
-rw-r--r--svgio/qa/cppunit/data/em_units.svg14
2 files changed, 34 insertions, 0 deletions
diff --git a/svgio/qa/cppunit/SvgImportTest.cxx b/svgio/qa/cppunit/SvgImportTest.cxx
index a46285ee7f64..cba534bfc5a5 100644
--- a/svgio/qa/cppunit/SvgImportTest.cxx
+++ b/svgio/qa/cppunit/SvgImportTest.cxx
@@ -70,6 +70,7 @@ class Test : public test::BootstrapFixture, public XmlTestTools
void testTdf101237();
void testTdf94765();
void testBehaviourWhenWidthAndHeightIsOrIsNotSet();
+ void testTdf97663();
Primitive2DSequence parseSvg(std::u16string_view aSource);
@@ -105,6 +106,7 @@ public:
CPPUNIT_TEST(testTdf101237);
CPPUNIT_TEST(testTdf94765);
CPPUNIT_TEST(testBehaviourWhenWidthAndHeightIsOrIsNotSet);
+ CPPUNIT_TEST(testTdf97663);
CPPUNIT_TEST_SUITE_END();
};
@@ -808,6 +810,24 @@ void Test::testBehaviourWhenWidthAndHeightIsOrIsNotSet()
}
}
+void Test::testTdf97663()
+{
+ Primitive2DSequence aSequence = parseSvg(u"/svgio/qa/cppunit/data/em_units.svg");
+ CPPUNIT_ASSERT_EQUAL(1, static_cast<int>(aSequence.getLength()));
+
+ drawinglayer::Primitive2dXmlDump dumper;
+ // This can be dumped to a file using dumper.dump(container, file_url)
+ Primitive2DContainer container = comphelper::sequenceToContainer<Primitive2DContainer>(aSequence);
+ xmlDocUniquePtr pDocument = dumper.dumpAndParse(container);
+
+ CPPUNIT_ASSERT (pDocument);
+
+ // tdf#97663: Without the fix in place, this test would have failed with
+ // - Expected: 236
+ // - Actual : 204
+ assertXPath(pDocument, "/primitive2D/transform/textsimpleportion[2]", "y", "236");
+}
+
CPPUNIT_TEST_SUITE_REGISTRATION(Test);
}
diff --git a/svgio/qa/cppunit/data/em_units.svg b/svgio/qa/cppunit/data/em_units.svg
new file mode 100644
index 000000000000..1ad4d3e3a769
--- /dev/null
+++ b/svgio/qa/cppunit/data/em_units.svg
@@ -0,0 +1,14 @@
+<svg xmlns="http://www.w3.org/2000/svg" width="10cm" height="10cm">
+
+ <style>
+ text {font-family: sans-serif; font-size: 36pt;}
+ new {font-family: sans-serif; font-size: 1em;}
+ </style>
+
+ <line x1="5cm" y1="5cm" x2="8cm" y2="5cm" stroke="black" />
+ <!-- 0.5in = 1.27cm = 36pt !-->
+ <line x1="5cm" y1="6.27cm" x2="8cm" y2="6.27cm" stroke="black" />
+ <text x="5cm" y="5cm" class="new">AWlll<tspan x="5cm" dy="1em">AWlll</tspan>
+ </text>
+</svg>
+