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

Jan-Marek Glogowski (via logerrit) logerrit at kemper.freedesktop.org
Tue Sep 15 04:42:21 UTC 2020


 vcl/inc/PhysicalFontFace.hxx                   |    8 +++
 vcl/inc/qt5/Qt5FontFace.hxx                    |    4 -
 vcl/inc/quartz/salgdi.h                        |    4 -
 vcl/inc/unx/freetype_glyphcache.hxx            |   13 ++++-
 vcl/inc/win/salgdi.h                           |    4 -
 vcl/qt5/Qt5FontFace.cxx                        |    2 
 vcl/qt5/Qt5Graphics_Text.cxx                   |    5 --
 vcl/source/gdi/pdfbuildin_fonts.cxx            |   56 +++++++++++++++++--------
 vcl/source/gdi/pdfbuildin_fonts.hxx            |    5 +-
 vcl/unx/generic/glyphs/freetype_glyphcache.cxx |   11 +++-
 10 files changed, 79 insertions(+), 33 deletions(-)

New commits:
commit fb50c96b4207f7effb9e656ae9c8ec8d25d625ca
Author:     Jan-Marek Glogowski <glogow at fbihome.de>
AuthorDate: Mon Sep 7 23:56:20 2020 +0200
Commit:     Jan-Marek Glogowski <glogow at fbihome.de>
CommitDate: Tue Sep 15 06:41:41 2020 +0200

    VCL register common functions in PhysicalFontFace
    
    This makes GetFontCapabilities and GetFontChatMap members of the
    PhysicalFontFace. These are implemented in all the real font face
    classes anyway. Also provide dummies for the PDF buildin fonts.
    
    Change-Id: Icb8cb14480ce1e020977b8f69892095d787982ce
    Reviewed-on: https://gerrit.libreoffice.org/c/core/+/102683
    Reviewed-by: Jan-Marek Glogowski <glogow at fbihome.de>
    Tested-by: Jenkins

diff --git a/vcl/inc/PhysicalFontFace.hxx b/vcl/inc/PhysicalFontFace.hxx
index 23af5be9169e..b6c0be37d99c 100644
--- a/vcl/inc/PhysicalFontFace.hxx
+++ b/vcl/inc/PhysicalFontFace.hxx
@@ -23,6 +23,7 @@
 #include <salhelper/simplereferenceobject.hxx>
 #include <rtl/ref.hxx>
 #include <vcl/dllapi.h>
+#include <vcl/fontcharmap.hxx>
 
 #include "fontattributes.hxx"
 
@@ -31,6 +32,11 @@ struct FontMatchStatus;
 class FontSelectPattern;
 class PhysicalFontFamily;
 
+namespace vcl
+{
+struct FontCapabilities;
+}
+
 struct FontMatchStatus
 {
 public:
@@ -59,6 +65,8 @@ public:
     int                     GetHeight() const           { return mnHeight; }
     int                     GetWidth() const            { return mnWidth; }
     virtual sal_IntPtr      GetFontId() const = 0;
+    virtual FontCharMapRef GetFontCharMap() const = 0;
+    virtual bool GetFontCapabilities(vcl::FontCapabilities&) const = 0;
 
     bool                    IsBetterMatch( const FontSelectPattern&, FontMatchStatus& ) const;
     sal_Int32               CompareWithSize( const PhysicalFontFace& ) const;
diff --git a/vcl/inc/qt5/Qt5FontFace.hxx b/vcl/inc/qt5/Qt5FontFace.hxx
index f9853af0f8c9..9c893d4f88c8 100644
--- a/vcl/inc/qt5/Qt5FontFace.hxx
+++ b/vcl/inc/qt5/Qt5FontFace.hxx
@@ -48,8 +48,8 @@ public:
     QFont CreateFont() const;
     int GetFontTable(const char pTagName[5], unsigned char*) const;
 
-    const FontCharMapRef& GetFontCharMap() const;
-    bool GetFontCapabilities(vcl::FontCapabilities& rFontCapabilities) const;
+    FontCharMapRef GetFontCharMap() const override;
+    bool GetFontCapabilities(vcl::FontCapabilities&) const override;
     bool HasChar(sal_uInt32 cChar) const;
 
     rtl::Reference<LogicalFontInstance>
diff --git a/vcl/inc/quartz/salgdi.h b/vcl/inc/quartz/salgdi.h
index a5c74c17705c..8058b68378b6 100644
--- a/vcl/inc/quartz/salgdi.h
+++ b/vcl/inc/quartz/salgdi.h
@@ -67,8 +67,8 @@ public:
     int                             GetFontTable( uint32_t nTagCode, unsigned char* ) const;
     int                             GetFontTable( const char pTagName[5], unsigned char* ) const;
 
-    FontCharMapRef                  GetFontCharMap() const;
-    bool                            GetFontCapabilities(vcl::FontCapabilities &rFontCapabilities) const;
+    FontCharMapRef GetFontCharMap() const override;
+    bool GetFontCapabilities(vcl::FontCapabilities&) const override;
     bool                            HasChar( sal_uInt32 cChar ) const;
 
     rtl::Reference<LogicalFontInstance> CreateFontInstance(const FontSelectPattern&) const override;
diff --git a/vcl/inc/unx/freetype_glyphcache.hxx b/vcl/inc/unx/freetype_glyphcache.hxx
index c375ba2ff5d4..4586c6fd2e6d 100644
--- a/vcl/inc/unx/freetype_glyphcache.hxx
+++ b/vcl/inc/unx/freetype_glyphcache.hxx
@@ -72,7 +72,8 @@ public:
 
     void                  AnnounceFont( PhysicalFontCollection* );
 
-    const FontCharMapRef& GetFontCharMap();
+    FontCharMapRef GetFontCharMap() const;
+    bool GetFontCapabilities(vcl::FontCapabilities&) const;
 
 private:
     friend class FreetypeManager;
@@ -87,7 +88,7 @@ private:
     sal_IntPtr      mnFontId;
     FontAttributes  maDevFontAttributes;
 
-    FontCharMapRef  mxFontCharMap;
+    mutable FontCharMapRef mxFontCharMap;
 };
 
 class FreetypeFontFace : public PhysicalFontFace
@@ -100,8 +101,16 @@ public:
 
     virtual rtl::Reference<LogicalFontInstance> CreateFontInstance( const FontSelectPattern& ) const override;
     virtual sal_IntPtr      GetFontId() const override { return mpFreetypeFontInfo->GetFontId(); }
+
+    FontCharMapRef GetFontCharMap() const override { return mpFreetypeFontInfo->GetFontCharMap(); }
+    inline bool GetFontCapabilities(vcl::FontCapabilities&) const override;
 };
 
+bool FreetypeFontFace::GetFontCapabilities(vcl::FontCapabilities& rFontCapabilities) const
+{
+    return mpFreetypeFontInfo->GetFontCapabilities(rFontCapabilities);
+}
+
 class SAL_DLLPUBLIC_RTTI FreetypeFontInstance : public LogicalFontInstance
 {
     friend rtl::Reference<LogicalFontInstance> FreetypeFontFace::CreateFontInstance(const FontSelectPattern&) const;
diff --git a/vcl/inc/win/salgdi.h b/vcl/inc/win/salgdi.h
index 5fe6645e7d2c..bf89853e1a8e 100644
--- a/vcl/inc/win/salgdi.h
+++ b/vcl/inc/win/salgdi.h
@@ -72,8 +72,8 @@ public:
     BYTE                    GetCharSet() const          { return meWinCharSet; }
     BYTE                    GetPitchAndFamily() const   { return mnPitchAndFamily; }
 
-    FontCharMapRef          GetFontCharMap() const;
-    bool GetFontCapabilities(vcl::FontCapabilities &rFontCapabilities) const;
+    FontCharMapRef GetFontCharMap() const override;
+    bool GetFontCapabilities(vcl::FontCapabilities&) const override;
 
 private:
     sal_IntPtr              mnId;
diff --git a/vcl/qt5/Qt5FontFace.cxx b/vcl/qt5/Qt5FontFace.cxx
index d02e61955103..ce349099030a 100644
--- a/vcl/qt5/Qt5FontFace.cxx
+++ b/vcl/qt5/Qt5FontFace.cxx
@@ -162,7 +162,7 @@ Qt5FontFace::CreateFontInstance(const FontSelectPattern& rFSD) const
     return new Qt5Font(*this, rFSD);
 }
 
-const FontCharMapRef& Qt5FontFace::GetFontCharMap() const
+FontCharMapRef Qt5FontFace::GetFontCharMap() const
 {
     if (m_xCharMap.is())
         return m_xCharMap;
diff --git a/vcl/qt5/Qt5Graphics_Text.cxx b/vcl/qt5/Qt5Graphics_Text.cxx
index 26b53ff694b8..0fe602d1ce3f 100644
--- a/vcl/qt5/Qt5Graphics_Text.cxx
+++ b/vcl/qt5/Qt5Graphics_Text.cxx
@@ -72,15 +72,14 @@ FontCharMapRef Qt5Graphics::GetFontCharMap() const
 {
     if (!m_pTextStyle[0])
         return FontCharMapRef(new FontCharMap());
-    return static_cast<const Qt5FontFace*>(m_pTextStyle[0]->GetFontFace())->GetFontCharMap();
+    return m_pTextStyle[0]->GetFontFace()->GetFontCharMap();
 }
 
 bool Qt5Graphics::GetFontCapabilities(vcl::FontCapabilities& rFontCapabilities) const
 {
     if (!m_pTextStyle[0])
         return false;
-    return static_cast<const Qt5FontFace*>(m_pTextStyle[0]->GetFontFace())
-        ->GetFontCapabilities(rFontCapabilities);
+    return m_pTextStyle[0]->GetFontFace()->GetFontCapabilities(rFontCapabilities);
 }
 
 void Qt5Graphics::GetDevFontList(PhysicalFontCollection* pPFC)
diff --git a/vcl/source/gdi/pdfbuildin_fonts.cxx b/vcl/source/gdi/pdfbuildin_fonts.cxx
index 41c208b93b67..4d74cf899069 100644
--- a/vcl/source/gdi/pdfbuildin_fonts.cxx
+++ b/vcl/source/gdi/pdfbuildin_fonts.cxx
@@ -21,8 +21,6 @@
 
 #include <rtl/strbuf.hxx>
 
-using namespace vcl;
-
 namespace vcl::pdf
 {
 OString BuildinFont::getNameObject() const
@@ -43,6 +41,16 @@ OString BuildinFont::getNameObject() const
     return aBuf.makeStringAndClear();
 }
 
+FontCharMapRef BuildinFont::GetFontCharMap() const
+{
+    assert(false && "pdf::BuildinFont doesn't provide correct char maps!");
+    if (m_xFontCharMap.is())
+        return m_xFontCharMap;
+
+    m_xFontCharMap = FontCharMap::GetDefaultMap(m_eCharSet != RTL_TEXTENCODING_MS_1252);
+    return m_xFontCharMap;
+}
+
 FontAttributes BuildinFont::GetFontAttributes() const
 {
     FontAttributes aDFA;
@@ -103,7 +111,8 @@ const BuildinFont BuildinFontFace::m_aBuildinFonts[14]
               600, 600, 600, 600, 600, 600, 600, 600, // 232 - 239
               600, 600, 600, 600, 600, 600, 600, 600, // 240 - 247
               600, 600, 600, 600, 600, 600, 600, 600 // 248 - 255
-          } },
+          },
+          nullptr },
 
         { "Courier", // family name
           "Italic", // style
@@ -149,7 +158,8 @@ const BuildinFont BuildinFontFace::m_aBuildinFonts[14]
               600, 600, 600, 600, 600, 600, 600, 600, // 232 - 239
               600, 600, 600, 600, 600, 600, 600, 600, // 240 - 247
               600, 600, 600, 600, 600, 600, 600, 600 // 248 - 255
-          } },
+          },
+          nullptr },
 
         { "Courier", // family name
           "Bold", // style
@@ -195,7 +205,8 @@ const BuildinFont BuildinFontFace::m_aBuildinFonts[14]
               600, 600, 600, 600, 600, 600, 600, 600, // 232 - 239
               600, 600, 600, 600, 600, 600, 600, 600, // 240 - 247
               600, 600, 600, 600, 600, 600, 600, 600 // 248 - 255
-          } },
+          },
+          nullptr },
 
         { "Courier", // family name
           "Bold Italic", // style
@@ -241,7 +252,8 @@ const BuildinFont BuildinFontFace::m_aBuildinFonts[14]
               600, 600, 600, 600, 600, 600, 600, 600, // 232 - 239
               600, 600, 600, 600, 600, 600, 600, 600, // 240 - 247
               600, 600, 600, 600, 600, 600, 600, 600 // 248 - 255
-          } },
+          },
+          nullptr },
 
         { "Helvetica", // family name
           "Normal", // style
@@ -287,7 +299,8 @@ const BuildinFont BuildinFontFace::m_aBuildinFonts[14]
               556,  556,  556, 556, 278,  278,  278,  278, // 232 - 239
               556,  556,  556, 556, 556,  556,  556,  584, // 240 - 247
               611,  556,  556, 556, 556,  500,  556,  500 // 248 - 255
-          } },
+          },
+          nullptr },
 
         { "Helvetica", // family name
           "Italic", // style
@@ -333,7 +346,8 @@ const BuildinFont BuildinFontFace::m_aBuildinFonts[14]
               556,  556,  556, 556, 278,  278,  278,  278, // 232 - 239
               556,  556,  556, 556, 556,  556,  556,  584, // 240 - 247
               611,  556,  556, 556, 556,  500,  556,  500 // 248 - 255
-          } },
+          },
+          nullptr },
 
         { "Helvetica", // family name
           "Bold", // style
@@ -379,7 +393,8 @@ const BuildinFont BuildinFontFace::m_aBuildinFonts[14]
               556, 556,  556, 556, 278,  278,  278,  278, // 232 - 239
               611, 611,  611, 611, 611,  611,  611,  584, // 240 - 247
               611, 611,  611, 611, 611,  556,  611,  556 // 248 - 255
-          } },
+          },
+          nullptr },
 
         { "Helvetica", // family name
           "Bold Italic", // style
@@ -425,7 +440,8 @@ const BuildinFont BuildinFontFace::m_aBuildinFonts[14]
               556, 556,  556, 556, 278,  278,  278,  278, // 232 - 239
               611, 611,  611, 611, 611,  611,  611,  584, // 240 - 247
               611, 611,  611, 611, 611,  556,  611,  556 // 248 - 255
-          } },
+          },
+          nullptr },
 
         { "Times", // family name
           "Normal", // style
@@ -471,7 +487,8 @@ const BuildinFont BuildinFontFace::m_aBuildinFonts[14]
               444, 444,  444, 444, 278, 278,  278, 278, // 232 - 239
               500, 500,  500, 500, 500, 500,  500, 564, // 240 - 247
               500, 500,  500, 500, 500, 500,  500, 500 // 248 - 255
-          } },
+          },
+          nullptr },
 
         { "Times", // family name
           "Italic", // style
@@ -517,7 +534,8 @@ const BuildinFont BuildinFontFace::m_aBuildinFonts[14]
               444, 444,  444, 444, 278, 278, 278, 278, // 232 - 239
               500, 500,  500, 500, 500, 500, 500, 675, // 240 - 247
               500, 500,  500, 500, 500, 444, 500, 444 // 248 - 255
-          } },
+          },
+          nullptr },
 
         { "Times", // family name
           "Bold", // style
@@ -563,7 +581,8 @@ const BuildinFont BuildinFontFace::m_aBuildinFonts[14]
               444, 444,  444, 444, 278,  278,  278,  278, // 232 - 239
               500, 556,  500, 500, 500,  500,  500,  570, // 240 - 247
               500, 556,  556, 556, 556,  500,  556,  500 // 248 - 255
-          } },
+          },
+          nullptr },
 
         { "Times", // family name
           "Bold Italic", // style
@@ -609,7 +628,8 @@ const BuildinFont BuildinFontFace::m_aBuildinFonts[14]
               444, 444,  444, 444, 278, 278,  278, 278, // 232 - 239
               500, 556,  500, 500, 500, 500,  500, 570, // 240 - 247
               500, 556,  556, 556, 556, 444,  500, 444 // 248 - 255
-          } },
+          },
+          nullptr },
 
         // The font name "Symbol" is too generic and causes plenty of trouble.
         // To ensure WYSIWIG the PDF-Base14 variant gets a not-confusable name
@@ -657,7 +677,8 @@ const BuildinFont BuildinFontFace::m_aBuildinFonts[14]
               384, 384, 384, 384,  494,  494, 494,  494, // 232 - 239
               0,   329, 274, 686,  686,  686, 384,  384, // 240 - 247
               384, 384, 384, 384,  494,  494, 494,  0 // 248 - 255
-          } },
+          },
+          nullptr },
 
         { "ZapfDingbats", // family name
           "Normal", // style
@@ -703,7 +724,8 @@ const BuildinFont BuildinFontFace::m_aBuildinFonts[14]
               883, 836, 836, 867, 867, 696, 696,  874, // 232 - 239
               0,   874, 760, 946, 771, 865, 771,  888, // 240 - 247
               967, 888, 831, 873, 927, 970, 918,  0 // 248 - 255
-          } }
+          },
+          nullptr }
 
       };
 
@@ -735,6 +757,6 @@ BuildinFontFace::CreateFontInstance(const FontSelectPattern& rFSP) const
     return new BuildinFontInstance(*this, rFSP);
 }
 
-} // namespace vcl
+} // namespace vcl::pdf
 
 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/vcl/source/gdi/pdfbuildin_fonts.hxx b/vcl/source/gdi/pdfbuildin_fonts.hxx
index 8e91cbcb95b4..b7bf17fdb405 100644
--- a/vcl/source/gdi/pdfbuildin_fonts.hxx
+++ b/vcl/source/gdi/pdfbuildin_fonts.hxx
@@ -38,8 +38,10 @@ struct BuildinFont
     FontWeight const m_eWeight;
     FontItalic const m_eItalic;
     int const m_aWidths[256];
+    mutable FontCharMapRef m_xFontCharMap;
 
     OString getNameObject() const;
+    FontCharMapRef GetFontCharMap() const;
     FontAttributes GetFontAttributes() const;
 };
 
@@ -55,7 +57,6 @@ public:
 
 class BuildinFontFace final : public PhysicalFontFace
 {
-private:
     static const BuildinFont m_aBuildinFonts[14];
     const BuildinFont& mrBuildin;
 
@@ -67,6 +68,8 @@ public:
 
     const BuildinFont& GetBuildinFont() const { return mrBuildin; }
     sal_IntPtr GetFontId() const override { return reinterpret_cast<sal_IntPtr>(&mrBuildin); }
+    FontCharMapRef GetFontCharMap() const override { return mrBuildin.GetFontCharMap(); }
+    bool GetFontCapabilities(vcl::FontCapabilities&) const override { return false; }
 
     static const BuildinFont& Get(int nId) { return m_aBuildinFonts[nId]; }
 };
diff --git a/vcl/unx/generic/glyphs/freetype_glyphcache.cxx b/vcl/unx/generic/glyphs/freetype_glyphcache.cxx
index 9ddf206572ac..6d8fec490c11 100644
--- a/vcl/unx/generic/glyphs/freetype_glyphcache.cxx
+++ b/vcl/unx/generic/glyphs/freetype_glyphcache.cxx
@@ -670,7 +670,12 @@ FontCharMapRef FreetypeFont::GetFontCharMap() const
     return mxFontInfo->GetFontCharMap();
 }
 
-const FontCharMapRef& FreetypeFontInfo::GetFontCharMap()
+bool FreetypeFont::GetFontCapabilities(vcl::FontCapabilities &rFontCapabilities) const
+{
+    return mxFontInfo->GetFontCapabilities(rFontCapabilities);
+}
+
+FontCharMapRef FreetypeFontInfo::GetFontCharMap() const
 {
     // check if the charmap is already cached
     if( mxFontCharMap.is() )
@@ -696,14 +701,14 @@ const FontCharMapRef& FreetypeFontInfo::GetFontCharMap()
     return mxFontCharMap;
 }
 
-bool FreetypeFont::GetFontCapabilities(vcl::FontCapabilities &rFontCapabilities) const
+bool FreetypeFontInfo::GetFontCapabilities(vcl::FontCapabilities &rFontCapabilities) const
 {
     bool bRet = false;
 
     sal_uLong nLength = 0;
 
     // load OS/2 table
-    const FT_Byte* pOS2 = mxFontInfo->GetTable("OS/2", &nLength);
+    const FT_Byte* pOS2 = GetTable("OS/2", &nLength);
     if (pOS2)
     {
         bRet = vcl::getTTCoverage(


More information about the Libreoffice-commits mailing list