svgio/qa/cppunit/SvgImportTest.cxx                       |   11 +++++++++++
 svgio/qa/cppunit/data/FontFamilyIncludingApostrophes.svg |    4 ++++
 svgio/source/svgreader/svgcharacternode.cxx              |    8 +++++++-
 3 files changed, 22 insertions(+), 1 deletion(-)

New commits:
commit 99d19aebd33d7834017ec09b83e081623e714112
Author:     Xisco Fauli <[email protected]>
AuthorDate: Thu Jan 22 19:40:31 2026 +0100
Commit:     Xisco Fauli <[email protected]>
CommitDate: Fri Jan 23 11:32:59 2026 +0100

    tdf#168372: remove surrounding apostrophes in font-family
    
    Change-Id: I94ef4ae8aa5aa7aa27602e959f80eb17c83679ce
    Reviewed-on: https://gerrit.libreoffice.org/c/core/+/197864
    Tested-by: Jenkins
    Reviewed-by: Xisco Fauli <[email protected]>

diff --git a/svgio/qa/cppunit/SvgImportTest.cxx 
b/svgio/qa/cppunit/SvgImportTest.cxx
index 20926c1dd0d8..fecad9645f5c 100644
--- a/svgio/qa/cppunit/SvgImportTest.cxx
+++ b/svgio/qa/cppunit/SvgImportTest.cxx
@@ -445,6 +445,17 @@ CPPUNIT_TEST_FIXTURE(Test, testFontsizePercentage)
     assertXPath(pDocument, "/primitive2D/transform/textsimpleportion[1]", 
"familyname", u"Times New Roman");
 }
 
+CPPUNIT_TEST_FIXTURE(Test, testFontFamilyIncludingApostrophes)
+{
+    //Check when font-size uses percentage and defined globally
+    xmlDocUniquePtr pDocument = 
dumpAndParseSvg(u"/svgio/qa/cppunit/data/FontFamilyIncludingApostrophes.svg");
+
+    assertXPath(pDocument, "/primitive2D/transform/textsimpleportion[1]", 
"fontcolor", u"#000000");
+    assertXPath(pDocument, "/primitive2D/transform/textsimpleportion[1]", 
"text", u"Text");
+    assertXPath(pDocument, "/primitive2D/transform/textsimpleportion[1]", 
"height", u"16");
+    assertXPath(pDocument, "/primitive2D/transform/textsimpleportion[1]", 
"familyname", u"Liberation Sans");
+}
+
 CPPUNIT_TEST_FIXTURE(Test, testFontsizeRelative)
 {
     //Check when font-size uses relative units (em,ex) and it's based on its 
parent's font-size
diff --git a/svgio/qa/cppunit/data/FontFamilyIncludingApostrophes.svg 
b/svgio/qa/cppunit/data/FontFamilyIncludingApostrophes.svg
new file mode 100644
index 000000000000..db13d7e3db07
--- /dev/null
+++ b/svgio/qa/cppunit/data/FontFamilyIncludingApostrophes.svg
@@ -0,0 +1,4 @@
+<?xml version="1.0" encoding="UTF-8" standalone="no"?>
+<svg viewBox="0 0 200 30" xmlns="http://www.w3.org/2000/svg";>
+  <text y="20" font-family="'Liberation Sans', Arial">Text</text>
+</svg>
diff --git a/svgio/source/svgreader/svgcharacternode.cxx 
b/svgio/source/svgreader/svgcharacternode.cxx
index eb5d16f0573c..1ea05de21219 100644
--- a/svgio/source/svgreader/svgcharacternode.cxx
+++ b/svgio/source/svgreader/svgcharacternode.cxx
@@ -105,7 +105,13 @@ namespace svgio::svgreader
             const SvgStringVector& rFontFamilyVector = 
rSvgStyleAttributes.getFontFamily();
             OUString aFontFamily(u"Times New Roman"_ustr);
             if(!rFontFamilyVector.empty())
-                aFontFamily=rFontFamilyVector[0];
+            {
+                aFontFamily = rFontFamilyVector[0];
+
+                // tdf#168372: remove surrounding apostrophes
+                if (aFontFamily.getLength() > 1 && aFontFamily.startsWith("'") 
&& aFontFamily.endsWith("'"))
+                    aFontFamily = aFontFamily.copy(1, aFontFamily.getLength() 
- 2);
+            }
 
             // #i122324# if the FontFamily name ends on ' embedded' it is 
probably a re-import
             // of a SVG export with font embedding. Remove this to make font 
matching work. This

Reply via email to