svx/source/tbxctrls/tbcontrl.cxx |   13 ++++++++++---
 1 file changed, 10 insertions(+), 3 deletions(-)

New commits:
commit 7087e5b9be3a099743f60ba721305f6cc607eaef
Author:     Caolán McNamara <caol...@redhat.com>
AuthorDate: Fri Apr 7 11:34:11 2023 +0100
Commit:     Caolán McNamara <caol...@redhat.com>
CommitDate: Fri Apr 7 16:55:00 2023 +0200

    Resolves: tdf#154680 don't mark an empty fontname as italic for "unknown"
    
    its used for 'ambigious' rather than 'unknown'
    
    Change-Id: I1aeb2f825c5e611e0a943a6ce5f3ab58658701bf
    Reviewed-on: https://gerrit.libreoffice.org/c/core/+/150121
    Tested-by: Jenkins
    Reviewed-by: Caolán McNamara <caol...@redhat.com>

diff --git a/svx/source/tbxctrls/tbcontrl.cxx b/svx/source/tbxctrls/tbcontrl.cxx
index 0ed31c52804b..17b574231ebf 100644
--- a/svx/source/tbxctrls/tbcontrl.cxx
+++ b/svx/source/tbxctrls/tbcontrl.cxx
@@ -354,6 +354,8 @@ protected:
                                          ".uno:CharEndPreviewFontName",
                                          aArgs );
     }
+
+    bool            CheckFontIsAvailable(std::u16string_view fontname);
     void            CheckAndMarkUnknownFont();
 
 public:
@@ -1759,16 +1761,21 @@ void SvxFontNameBox_Base::FillList()
     m_xWidget->select_entry_region(nStartPos, nEndPos);
 }
 
+bool SvxFontNameBox_Base::CheckFontIsAvailable(std::u16string_view fontname)
+{
+    lcl_GetDocFontList(&pFontList, this);
+    return pFontList && pFontList->IsAvailable(fontname);
+}
+
 void SvxFontNameBox_Base::CheckAndMarkUnknownFont()
 {
     if (mbCheckingUnknownFont) //tdf#117537 block rentry
         return;
     mbCheckingUnknownFont = true;
     OUString fontname = m_xWidget->get_active_text();
-    lcl_GetDocFontList( &pFontList, this );
-    // If the font is unknown, show it in italic.
+    // tdf#154680 If a font is set and that font is unknown, show it in italic.
     vcl::Font font = m_xWidget->get_entry_font();
-    if( pFontList != nullptr && pFontList->IsAvailable( fontname ))
+    if (fontname.isEmpty() || CheckFontIsAvailable(fontname))
     {
         if( font.GetItalic() != ITALIC_NONE )
         {

Reply via email to