svgio/qa/cppunit/SvgImportTest.cxx          |    6 ++++++
 svgio/qa/cppunit/data/RTLtext.svg           |    6 ++++--
 svgio/source/svgreader/svgcharacternode.cxx |   12 ++++++++++--
 3 files changed, 20 insertions(+), 4 deletions(-)

New commits:
commit 635d1a1bc5b65b6a7de39258220c1e41041e7d90
Author:     Xisco Fauli <xiscofa...@libreoffice.org>
AuthorDate: Tue Sep 16 10:40:27 2025 +0200
Commit:     Adolfo Jayme Barrientos <fit...@ubuntu.com>
CommitDate: Wed Sep 17 19:36:20 2025 +0200

    tdf#168378: invert text anchor in RTL
    
    Change-Id: Ia9b7e526ab20cbcdb521f965a5a2dc0726894209
    Reviewed-on: https://gerrit.libreoffice.org/c/core/+/191018
    Tested-by: Jenkins
    Reviewed-by: Xisco Fauli <xiscofa...@libreoffice.org>
    Signed-off-by: Xisco Fauli <xiscofa...@libreoffice.org>
    Reviewed-on: https://gerrit.libreoffice.org/c/core/+/191031
    Reviewed-by: Adolfo Jayme Barrientos <fit...@ubuntu.com>
    (cherry picked from commit 7de70bdfeb70075800535bdf173941ba8e5cdc38)
    Reviewed-on: https://gerrit.libreoffice.org/c/core/+/191097

diff --git a/svgio/qa/cppunit/SvgImportTest.cxx 
b/svgio/qa/cppunit/SvgImportTest.cxx
index e738d8bb76e3..19295096b95c 100644
--- a/svgio/qa/cppunit/SvgImportTest.cxx
+++ b/svgio/qa/cppunit/SvgImportTest.cxx
@@ -2121,6 +2121,12 @@ CPPUNIT_TEST_FIXTURE(Test, testRTLtext)
 
     assertXPath(pDocument, "/primitive2D/transform/textsimpleportion[1]", 
"text", u"داستان SVG 1.1 SE طولا ني است.");
     assertXPath(pDocument, "/primitive2D/transform/textsimpleportion[1]", 
"rtl", u"true");
+
+    assertXPath(pDocument, "/primitive2D/transform/textsimpleportion[2]", 
"text", u"داستان SVG 1.2 SE طولا ني است.");
+    assertXPath(pDocument, "/primitive2D/transform/textsimpleportion[2]", 
"rtl", u"true");
+
+    assertXPath(pDocument, "/primitive2D/transform/textsimpleportion[3]", 
"text", u"داستان SVG 1.3 SE طولا ني است.");
+    assertXPath(pDocument, "/primitive2D/transform/textsimpleportion[3]", 
"rtl", u"true");
 }
 
 CPPUNIT_TEST_FIXTURE(Test, testCssClassRedefinition)
diff --git a/svgio/qa/cppunit/data/RTLtext.svg 
b/svgio/qa/cppunit/data/RTLtext.svg
index f360fc559dc6..40dff70d904e 100644
--- a/svgio/qa/cppunit/data/RTLtext.svg
+++ b/svgio/qa/cppunit/data/RTLtext.svg
@@ -1,7 +1,9 @@
 <svg
-  viewBox="0 0 600 72"
+  width="600 px" height="600 px"
   xmlns="http://www.w3.org/2000/svg";
   direction="rtl"
   font-family="DejaVu Sans">
-  <text x="300" y="50" text-anchor="middle">داستان SVG 1.1 SE طولا ني 
است.</text>
+  <text x="300" y="50" text-anchor="start">داستان SVG 1.1 SE طولا ني 
است.</text>
+  <text x="300" y="100" text-anchor="middle">داستان SVG 1.2 SE طولا ني 
است.</text>
+  <text x="300" y="150" text-anchor="end">داستان SVG 1.3 SE طولا ني است.</text>
 </svg>
diff --git a/svgio/source/svgreader/svgcharacternode.cxx 
b/svgio/source/svgreader/svgcharacternode.cxx
index e0ef204c4452..4e7c8e4794c5 100644
--- a/svgio/source/svgreader/svgcharacternode.cxx
+++ b/svgio/source/svgreader/svgcharacternode.cxx
@@ -236,6 +236,8 @@ namespace svgio::svgreader
                 // get TextAlign
                 TextAlign aTextAlign(rSvgStyleAttributes.getTextAlign());
 
+                bool bRTL(FontDirection::RTL == 
rSvgStyleAttributes.getFontDirection());
+
                 // map TextAnchor to TextAlign, there seems not to be a 
difference
                 if(TextAnchor::notset != rSvgStyleAttributes.getTextAnchor())
                 {
@@ -243,7 +245,10 @@ namespace svgio::svgreader
                     {
                         case TextAnchor::start:
                         {
-                            aTextAlign = TextAlign::left;
+                            if (bRTL)
+                                aTextAlign = TextAlign::right;
+                            else
+                                aTextAlign = TextAlign::left;
                             break;
                         }
                         case TextAnchor::middle:
@@ -253,7 +258,10 @@ namespace svgio::svgreader
                         }
                         case TextAnchor::end:
                         {
-                            aTextAlign = TextAlign::right;
+                            if (bRTL)
+                                aTextAlign = TextAlign::left;
+                            else
+                                aTextAlign = TextAlign::right;
                             break;
                         }
                         default:

Reply via email to