[Libreoffice-commits] core.git: vcl/qt5

Jan-Marek Glogowski (via logerrit) logerrit at kemper.freedesktop.org
Tue Mar 3 14:58:42 UTC 2020


 vcl/qt5/Qt5Font.cxx |  103 ++++++++++++++++++++++++++++------------------------
 1 file changed, 56 insertions(+), 47 deletions(-)

New commits:
commit b9a124aae67cbd64917f07f2dca6603f149c018b
Author:     Jan-Marek Glogowski <jan-marek.glogowski at extern.cib.de>
AuthorDate: Tue Mar 3 12:59:13 2020 +0100
Commit:     Jan-Marek Glogowski <glogow at fbihome.de>
CommitDate: Tue Mar 3 15:58:07 2020 +0100

    Qt5 just ignore invalid font attributes
    
    This ignores the *_DONTKNOW and _FORCE_EQUAL_SIZE values, except
    for the stretch, where we map DONTKNOW to QFont::AnyStretch.
    
    Change-Id: Ifdf55e798566681852ad4b585f4aeb0ebfbd1cf9
    Reviewed-on: https://gerrit.libreoffice.org/c/core/+/89884
    Tested-by: Jenkins
    Reviewed-by: Jan-Marek Glogowski <glogow at fbihome.de>

diff --git a/vcl/qt5/Qt5Font.cxx b/vcl/qt5/Qt5Font.cxx
index 832508038b4d..2ab614043639 100644
--- a/vcl/qt5/Qt5Font.cxx
+++ b/vcl/qt5/Qt5Font.cxx
@@ -23,100 +23,109 @@
 #include <QtGui/QFont>
 #include <QtGui/QRawFont>
 
-static QFont::Weight toWeight(FontWeight eWeight)
+static inline void applyWeight(Qt5Font& rFont, FontWeight eWeight)
 {
     switch (eWeight)
     {
         case WEIGHT_THIN:
-            return QFont::Thin;
+            rFont.setWeight(QFont::Thin);
+            break;
         case WEIGHT_ULTRALIGHT:
-            return QFont::ExtraLight;
+            rFont.setWeight(QFont::ExtraLight);
+            break;
         case WEIGHT_LIGHT:
-            return QFont::Light;
+            rFont.setWeight(QFont::Light);
+            break;
         case WEIGHT_SEMILIGHT:
             [[fallthrough]];
-        case WEIGHT_DONTKNOW:
-            [[fallthrough]];
         case WEIGHT_NORMAL:
-            return QFont::Normal;
+            rFont.setWeight(QFont::Normal);
+            break;
         case WEIGHT_MEDIUM:
-            return QFont::Medium;
+            rFont.setWeight(QFont::Medium);
+            break;
         case WEIGHT_SEMIBOLD:
-            return QFont::DemiBold;
+            rFont.setWeight(QFont::DemiBold);
+            break;
         case WEIGHT_BOLD:
-            return QFont::Bold;
+            rFont.setWeight(QFont::Bold);
+            break;
         case WEIGHT_ULTRABOLD:
-            return QFont::ExtraBold;
+            rFont.setWeight(QFont::ExtraBold);
+            break;
         case WEIGHT_BLACK:
-            return QFont::Black;
-        case FontWeight_FORCE_EQUAL_SIZE:
-            assert(false && "FontWeight_FORCE_EQUAL_SIZE not implementable for QFont");
+            rFont.setWeight(QFont::Black);
+            break;
+        default:
+            break;
     }
-
-    // so we would get enum not handled warning
-    return QFont::Normal;
 }
 
-static int toStretch(FontWidth eWidthType)
+static inline void applyStretch(Qt5Font& rFont, FontWidth eWidthType)
 {
     switch (eWidthType)
     {
         case WIDTH_DONTKNOW:
-            return QFont::AnyStretch;
+            rFont.setStretch(QFont::AnyStretch);
+            break;
         case WIDTH_ULTRA_CONDENSED:
-            return QFont::UltraCondensed;
+            rFont.setStretch(QFont::UltraCondensed);
+            break;
         case WIDTH_EXTRA_CONDENSED:
-            return QFont::ExtraCondensed;
+            rFont.setStretch(QFont::ExtraCondensed);
+            break;
         case WIDTH_CONDENSED:
-            return QFont::Condensed;
+            rFont.setStretch(QFont::Condensed);
+            break;
         case WIDTH_SEMI_CONDENSED:
-            return QFont::SemiCondensed;
+            rFont.setStretch(QFont::SemiCondensed);
+            break;
         case WIDTH_NORMAL:
-            return QFont::Unstretched;
+            rFont.setStretch(QFont::Unstretched);
+            break;
         case WIDTH_SEMI_EXPANDED:
-            return QFont::SemiExpanded;
+            rFont.setStretch(QFont::SemiExpanded);
+            break;
         case WIDTH_EXPANDED:
-            return QFont::Expanded;
+            rFont.setStretch(QFont::Expanded);
+            break;
         case WIDTH_EXTRA_EXPANDED:
-            return QFont::ExtraExpanded;
+            rFont.setStretch(QFont::ExtraExpanded);
+            break;
         case WIDTH_ULTRA_EXPANDED:
-            return QFont::UltraExpanded;
-        case FontWidth_FORCE_EQUAL_SIZE:
-            assert(false && "FontWidth_FORCE_EQUAL_SIZE not implementable for QFont");
+            rFont.setStretch(QFont::UltraExpanded);
+            break;
+        default:
+            break;
     }
-
-    // so we would get enum not handled warning
-    return QFont::AnyStretch;
 }
 
-static QFont::Style toStyle(FontItalic eItalic)
+static inline void applyStyle(Qt5Font& rFont, FontItalic eItalic)
 {
     switch (eItalic)
     {
-        case ITALIC_DONTKNOW:
-            [[fallthrough]];
         case ITALIC_NONE:
-            return QFont::Style::StyleNormal;
+            rFont.setStyle(QFont::Style::StyleNormal);
+            break;
         case ITALIC_OBLIQUE:
-            return QFont::Style::StyleOblique;
+            rFont.setStyle(QFont::Style::StyleOblique);
+            break;
         case ITALIC_NORMAL:
-            return QFont::Style::StyleItalic;
-        case FontItalic_FORCE_EQUAL_SIZE:
-            assert(false && "FontItalic_FORCE_EQUAL_SIZE not implementable for QFont");
+            rFont.setStyle(QFont::Style::StyleItalic);
+            break;
+        default:
+            break;
     }
-
-    // so we would get enum not handled warning
-    return QFont::Style::StyleNormal;
 }
 
 Qt5Font::Qt5Font(const PhysicalFontFace& rPFF, const FontSelectPattern& rFSP)
     : LogicalFontInstance(rPFF, rFSP)
 {
     setFamily(toQString(rPFF.GetFamilyName()));
-    setWeight(toWeight(rPFF.GetWeight()));
+    applyWeight(*this, rPFF.GetWeight());
     setPixelSize(rFSP.mnHeight);
-    setStretch(toStretch(rPFF.GetWidthType()));
-    setStyle(toStyle(rFSP.GetItalic()));
+    applyStretch(*this, rPFF.GetWidthType());
+    applyStyle(*this, rFSP.GetItalic());
 }
 
 static hb_blob_t* getFontTable(hb_face_t*, hb_tag_t nTableTag, void* pUserData)


More information about the Libreoffice-commits mailing list