cui/source/dialogs/cuicharmap.cxx              |   12 ++++++++----
 sw/qa/uitest/writer_tests3/specialCharacter.py |   17 ++++++++++++++++-
 2 files changed, 24 insertions(+), 5 deletions(-)

New commits:
commit 7a2bd19355d78551f9ce253fca69d37881d1d1c1
Author:     Andreas Heinisch <andreas.heini...@yahoo.de>
AuthorDate: Tue Mar 22 21:12:09 2022 +0100
Commit:     Andreas Heinisch <andreas.heini...@yahoo.de>
CommitDate: Sat Apr 9 14:31:09 2022 +0200

    tdf#56363 - Search font family without the font feature after the colon
    
    In the special character dialog, search font family without the font
    feature after the colon in order to find the correct item in the font
    combobox.
    
    Change-Id: I60d068bb22782bcce062365a8d4d53e15ec34c76
    Reviewed-on: https://gerrit.libreoffice.org/c/core/+/131953
    Tested-by: Jenkins
    Reviewed-by: Andreas Heinisch <andreas.heini...@yahoo.de>

diff --git a/cui/source/dialogs/cuicharmap.cxx 
b/cui/source/dialogs/cuicharmap.cxx
index 95678899df90..42c12c5e3ce9 100644
--- a/cui/source/dialogs/cuicharmap.cxx
+++ b/cui/source/dialogs/cuicharmap.cxx
@@ -477,7 +477,7 @@ void SvxCharacterMap::init()
     // the font may not be in the list =>
     // try to find a font name token in list and select found font,
     // else select topmost entry
-    bool bFound = (m_xFontLB->find_text(aDefStr) == -1);
+    bool bFound = (m_xFontLB->find_text(aDefStr) != -1);
     if (!bFound)
     {
         sal_Int32 nIndex = 0;
@@ -611,17 +611,21 @@ void SvxCharacterMap::SetCharFont( const vcl::Font& rFont 
)
     // like "Times New Roman;Times" resolved
     vcl::Font aTmp(m_xVirDev->GetFontMetric(rFont));
 
-    if (aTmp.GetFamilyName() == "StarSymbol" && 
m_xFontLB->find_text(aTmp.GetFamilyName()) == -1)
+    // tdf#56363 - search font family without the font feature after the colon
+    OUString sFontFamilyName = aTmp.GetFamilyName();
+    if (const sal_Int32 nIndex = sFontFamilyName.indexOf(":"); nIndex != -1)
+        sFontFamilyName = sFontFamilyName.copy(0, nIndex);
+    if (sFontFamilyName == "StarSymbol" && 
m_xFontLB->find_text(sFontFamilyName) == -1)
     {
         //if for some reason, like font in an old document, StarSymbol is 
requested and it's not available, then
         //try OpenSymbol instead
         aTmp.SetFamilyName("OpenSymbol");
     }
 
-    if (m_xFontLB->find_text(aTmp.GetFamilyName()) == -1)
+    if (m_xFontLB->find_text(sFontFamilyName) == -1)
         return;
 
-    m_xFontLB->set_active_text(aTmp.GetFamilyName());
+    m_xFontLB->set_active_text(sFontFamilyName);
     aFont = aTmp;
     FontSelectHdl(*m_xFontLB);
     if (m_xSubsetLB->get_count())
diff --git a/sw/qa/uitest/writer_tests3/specialCharacter.py 
b/sw/qa/uitest/writer_tests3/specialCharacter.py
index 577b8b531984..494875024c1e 100644
--- a/sw/qa/uitest/writer_tests3/specialCharacter.py
+++ b/sw/qa/uitest/writer_tests3/specialCharacter.py
@@ -12,10 +12,25 @@ from libreoffice.uno.propertyvalue import mkPropertyValues
 from uitest.uihelper.common import get_state_as_dict
 from uitest.uihelper.common import select_pos
 
-
 # specialcharacters.ui
 class specialCharacter(UITestCase):
 
+    def test_tdf56363(self):
+        with self.ui_test.create_doc_in_start_center("writer") as document:
+            xWriterDoc = self.xUITest.getTopFocusWindow()
+
+            # Insert a font including a font feature into the font name 
combobox
+            xFontName = xWriterDoc.getChild("fontnamecombobox")
+            xFontName.executeAction("TYPE", 
mkPropertyValues({"KEYCODE":"CTRL+A"}))
+            xFontName.executeAction("TYPE", 
mkPropertyValues({"TEXT":"Liberation Sans:smcp"}))
+            xFontName.executeAction("TYPE", mkPropertyValues({"KEYCODE": 
"RETURN"}))
+
+            # Open special character dialog and check selected font name
+            with 
self.ui_test.execute_dialog_through_command(".uno:InsertSymbol", 
close_button="cancel") as xDialog:
+                xComboFont = xDialog.getChild("fontlb")
+                # Without the fix in place, no font would be selected
+                self.assertEqual(get_state_as_dict(xComboFont)["Text"], 
"Liberation Sans")
+
     def test_special_character(self):
         with self.ui_test.create_doc_in_start_center("writer") as document:
 

Reply via email to