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

Jan-Marek Glogowski glogow at fbihome.de
Fri Dec 15 10:16:59 UTC 2017


 vcl/inc/PhysicalFontFace.hxx                   |   31 ++++++-------------------
 vcl/inc/fontinstance.hxx                       |   14 ++++++++---
 vcl/inc/quartz/salgdi.h                        |    1 
 vcl/inc/unx/freetype_glyphcache.hxx            |   17 +++++++++++++
 vcl/inc/unx/glyphcache.hxx                     |   15 ------------
 vcl/inc/win/winlayout.hxx                      |   17 ++++++-------
 vcl/qt5/Qt5FontFace.cxx                        |    5 ----
 vcl/qt5/Qt5FontFace.hxx                        |    1 
 vcl/quartz/ctfonts.cxx                         |    5 ----
 vcl/source/font/PhysicalFontFace.cxx           |    5 ++++
 vcl/source/gdi/pdfwriter_impl.cxx              |    7 -----
 vcl/source/gdi/pdfwriter_impl.hxx              |    1 
 vcl/unx/generic/glyphs/freetype_glyphcache.cxx |    5 +---
 vcl/unx/generic/print/genpspgraphics.cxx       |   15 +++---------
 vcl/win/gdi/winlayout.cxx                      |    5 +---
 15 files changed, 58 insertions(+), 86 deletions(-)

New commits:
commit 8b700794b2746070814e9ff416ecd7bbb1c902e7
Author: Jan-Marek Glogowski <glogow at fbihome.de>
Date:   Thu Dec 14 18:42:57 2017 +0100

    Protect all LogicalFontInstance constructors
    
    This way LogicalFontInstance can just be constructed by a
    PhysicalFontFace based factory.
    
    The patch also drops the wrong "Java logical font" comment
    added by commit 125cdf3404e60cf78f2a5547e9a06ce994df5c8e.
    
    Change-Id: Ibd5d7da0c3a65dbfa2c8ae6b05cf616d39b749f2
    Reviewed-on: https://gerrit.libreoffice.org/46475
    Tested-by: Jenkins <ci at libreoffice.org>
    Reviewed-by: Jan-Marek Glogowski <glogow at fbihome.de>

diff --git a/vcl/inc/PhysicalFontFace.hxx b/vcl/inc/PhysicalFontFace.hxx
index 94d7eb5ebc44..ff708b99cfb8 100644
--- a/vcl/inc/PhysicalFontFace.hxx
+++ b/vcl/inc/PhysicalFontFace.hxx
@@ -46,33 +46,18 @@ public:
 // TODO: get rid of height/width for scalable fonts
 // TODO: make cloning cheaper
 
-// abstract base class for physical font faces
-
-// Note about physical and logical fonts:
-//
-// A physical font is a concept we have taken from the Java world
-//
-// From https://docs.oracle.com/javase/tutorial/2d/text/fonts.html
-//
-//      There are two types of fonts: physical fonts and logical fonts.
-//      Physical fonts are the actual font libraries consisting of, for
-//      example, TrueType or PostScript Type 1 fonts. The physical fonts
-//      may be Time, Helvetica, Courier, or any number of other fonts,
-//      including international fonts. Logical fonts are the following
-//      five font families: Serif, SansSerif, Monospaced, Dialog, and
-//      DialogInput. These logical fonts are not actual font libraries.
-//      Instead, the logical font names are mapped to physical fonts by
-//      the Java runtime environment.
-
+/**
+ * abstract base class for physical font faces
+ *
+ * It acts as a factory for its corresponding LogicalFontInstances and
+ * can be extended to cache device and font instance specific data.
+ */
 class VCL_PLUGIN_PUBLIC PhysicalFontFace : public FontAttributes
 {
 public:
     virtual                ~PhysicalFontFace() {}
 
-    // by using an PhysicalFontFace object as a factory for its corresponding
-    // LogicalFontInstance can be extended to cache device and font instance
-    // specific data
-    virtual LogicalFontInstance*  CreateFontInstance( const FontSelectPattern& ) const = 0;
+    virtual LogicalFontInstance* CreateFontInstance(const FontSelectPattern&) const;
     virtual PhysicalFontFace* Clone() const = 0;
 
     int                     GetHeight() const           { return mnHeight; }
@@ -84,7 +69,7 @@ public:
     sal_Int32               CompareIgnoreSize( const PhysicalFontFace& ) const;
 
 protected:
-    explicit                PhysicalFontFace( const FontAttributes& );
+    explicit PhysicalFontFace(const FontAttributes&);
     void                    SetBitmapSize( int nW, int nH ) { mnWidth=nW; mnHeight=nH; }
 
     long                    mnWidth;    // Width (in pixels)
diff --git a/vcl/inc/fontinstance.hxx b/vcl/inc/fontinstance.hxx
index 0158e972a990..7595c79036cd 100644
--- a/vcl/inc/fontinstance.hxx
+++ b/vcl/inc/fontinstance.hxx
@@ -22,21 +22,24 @@
 
 #include "fontselect.hxx"
 #include "impfontmetricdata.hxx"
+#include "PhysicalFontFace.hxx"
 
 #include <unordered_map>
 
-class ImplFontCache;
 class ConvertChar;
+class ImplFontCache;
 
 // TODO: allow sharing of metrics for related fonts
 
 class VCL_PLUGIN_PUBLIC LogicalFontInstance
 {
-public:
-    explicit        LogicalFontInstance( const FontSelectPattern& );
-    virtual         ~LogicalFontInstance();
+    // just declaring the factory function doesn't work AKA
+    // friend LogicalFontInstance* PhysicalFontFace::CreateFontInstance(const FontSelectPattern&) const;
+    friend class PhysicalFontFace;
 
 public: // TODO: make data members private
+    virtual ~LogicalFontInstance();
+
     ImplFontCache * mpFontCache;
     FontSelectPattern  maFontSelData;       // FontSelectionData
     ImplFontMetricDataRef mxFontMetric;        // Font attributes
@@ -52,6 +55,9 @@ public: // TODO: make data members private
     bool            GetFallbackForUnicode( sal_UCS4, FontWeight eWeight, OUString* pFontName ) const;
     void            IgnoreFallbackForUnicode( sal_UCS4, FontWeight eWeight, const OUString& rFontName );
 
+protected:
+    explicit LogicalFontInstance(const FontSelectPattern&);
+
 private:
     // cache of Unicode characters and replacement font names
     // TODO: a fallback map can be shared with many other ImplFontEntries
diff --git a/vcl/inc/quartz/salgdi.h b/vcl/inc/quartz/salgdi.h
index 5a346b6a2098..17faec998c26 100644
--- a/vcl/inc/quartz/salgdi.h
+++ b/vcl/inc/quartz/salgdi.h
@@ -63,7 +63,6 @@ public:
     virtual                         ~CoreTextFontFace() override;
 
     PhysicalFontFace*               Clone() const override;
-    LogicalFontInstance*            CreateFontInstance( const FontSelectPattern& ) const override;
     sal_IntPtr                      GetFontId() const override;
 
     int                             GetFontTable( const char pTagName[5], unsigned char* ) const;
diff --git a/vcl/inc/unx/freetype_glyphcache.hxx b/vcl/inc/unx/freetype_glyphcache.hxx
index a01992fa60c8..eb825b7c3f26 100644
--- a/vcl/inc/unx/freetype_glyphcache.hxx
+++ b/vcl/inc/unx/freetype_glyphcache.hxx
@@ -22,6 +22,7 @@
 
 #include <unx/glyphcache.hxx>
 #include <PhysicalFontFace.hxx>
+#include <fontinstance.hxx>
 
 // FreetypeFontFile has the responsibility that a font file is only mapped once.
 // (#86621#) the old directly ft-managed solution caused it to be mapped
@@ -118,6 +119,22 @@ public:
     virtual sal_IntPtr      GetFontId() const override { return mpFreetypeFontInfo->GetFontId(); }
 };
 
+// a class for cache entries for physical font instances that are based on serverfonts
+class VCL_DLLPUBLIC FreetypeFontInstance : public LogicalFontInstance
+{
+    friend LogicalFontInstance* FreetypeFontFace::CreateFontInstance(const FontSelectPattern&) const;
+
+    FreetypeFont* mpFreetypeFont;
+
+protected:
+    explicit FreetypeFontInstance(const FontSelectPattern&);
+
+public:
+    virtual ~FreetypeFontInstance() override;
+
+    void SetFreetypeFont(FreetypeFont* p);
+};
+
 #endif // INCLUDED_VCL_GENERIC_GLYPHS_GCACH_FTYP_HXX
 
 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/vcl/inc/unx/glyphcache.hxx b/vcl/inc/unx/glyphcache.hxx
index c512628862fa..42b2f4244450 100644
--- a/vcl/inc/unx/glyphcache.hxx
+++ b/vcl/inc/unx/glyphcache.hxx
@@ -30,9 +30,9 @@
 #include <vcl/dllapi.h>
 #include <vcl/metric.hxx>
 
-#include <fontinstance.hxx>
 #include <sallayout.hxx>
 #include <fontattributes.hxx>
+#include <fontselect.hxx>
 #include <impfontmetricdata.hxx>
 #include <hb-ot.h>
 
@@ -194,19 +194,6 @@ private:
     hb_font_t*              mpHbFont;
 };
 
-// a class for cache entries for physical font instances that are based on serverfonts
-class VCL_DLLPUBLIC FreetypeFontInstance : public LogicalFontInstance
-{
-public:
-                            FreetypeFontInstance( FontSelectPattern const & );
-    virtual                 ~FreetypeFontInstance() override;
-
-    void                    SetFreetypeFont(FreetypeFont* p);
-
-private:
-    FreetypeFont*           mpFreetypeFont;
-};
-
 #endif // INCLUDED_VCL_INC_GENERIC_GLYPHCACHE_HXX
 
 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/vcl/inc/win/winlayout.hxx b/vcl/inc/win/winlayout.hxx
index af9eaef473e1..4e1174899d8e 100644
--- a/vcl/inc/win/winlayout.hxx
+++ b/vcl/inc/win/winlayout.hxx
@@ -145,21 +145,20 @@ public:
 // win32 specific physical font instance
 class WinFontInstance : public LogicalFontInstance
 {
+    friend LogicalFontInstance* WinFontFace::CreateFontInstance(const FontSelectPattern&) const;
+
 public:
-    explicit                WinFontInstance( FontSelectPattern const & );
     virtual                 ~WinFontInstance() override;
 
-private:
-    // TODO: also add HFONT??? Watch out for issues with too many active fonts...
-
-    GlyphCache maGlyphCache;
 public:
     bool CacheGlyphToAtlas(HDC hDC, HFONT hFont, int nGlyphIndex, SalGraphics& rGraphics);
+    GlyphCache& GetGlyphCache() { return maGlyphCache; }
 
-    GlyphCache& GetGlyphCache()
-    {
-        return maGlyphCache;
-    }
+private:
+    explicit WinFontInstance(const FontSelectPattern&);
+
+    // TODO: also add HFONT??? Watch out for issues with too many active fonts...
+    GlyphCache maGlyphCache;
 };
 
 class TextOutRenderer
diff --git a/vcl/qt5/Qt5FontFace.cxx b/vcl/qt5/Qt5FontFace.cxx
index 6d7074bbbb51..a73e4528ec05 100644
--- a/vcl/qt5/Qt5FontFace.cxx
+++ b/vcl/qt5/Qt5FontFace.cxx
@@ -110,7 +110,4 @@ bool Qt5FontFace::GetFontCapabilities(vcl::FontCapabilities& rFontCapabilities)
 
 PhysicalFontFace* Qt5FontFace::Clone() const { return new Qt5FontFace(*this); }
 
-LogicalFontInstance* Qt5FontFace::CreateFontInstance(const FontSelectPattern& rFSD) const
-{
-    return new LogicalFontInstance(rFSD);
-}
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/vcl/qt5/Qt5FontFace.hxx b/vcl/qt5/Qt5FontFace.hxx
index 259b95939556..bd33893609d8 100644
--- a/vcl/qt5/Qt5FontFace.hxx
+++ b/vcl/qt5/Qt5FontFace.hxx
@@ -39,7 +39,6 @@ public:
     static Qt5FontFace* fromQFont(const QFont& rFont);
 
     PhysicalFontFace* Clone() const override;
-    LogicalFontInstance* CreateFontInstance(const FontSelectPattern&) const override;
     sal_IntPtr GetFontId() const override;
 
     int GetFontTable(const char pTagName[5], unsigned char*) const;
diff --git a/vcl/quartz/ctfonts.cxx b/vcl/quartz/ctfonts.cxx
index c31dcc329e2b..2a09ffc8a87c 100644
--- a/vcl/quartz/ctfonts.cxx
+++ b/vcl/quartz/ctfonts.cxx
@@ -268,11 +268,6 @@ PhysicalFontFace* CoreTextFontFace::Clone() const
     return new CoreTextFontFace( *this);
 }
 
-LogicalFontInstance* CoreTextFontFace::CreateFontInstance( const FontSelectPattern& rFSD ) const
-{
-    return new LogicalFontInstance( rFSD);
-}
-
 int CoreTextFontFace::GetFontTable( const char pTagName[5], unsigned char* pResultBuf ) const
 {
     SAL_WARN_IF( pTagName[4]!='\0', "vcl", "CoreTextFontFace::GetFontTable with invalid tagname!" );
diff --git a/vcl/source/font/PhysicalFontFace.cxx b/vcl/source/font/PhysicalFontFace.cxx
index dc911643f016..40acbb8fb99c 100644
--- a/vcl/source/font/PhysicalFontFace.cxx
+++ b/vcl/source/font/PhysicalFontFace.cxx
@@ -37,6 +37,11 @@ PhysicalFontFace::PhysicalFontFace( const FontAttributes& rDFA )
             SetSymbolFlag( true );
 }
 
+LogicalFontInstance* PhysicalFontFace::CreateFontInstance(const FontSelectPattern& rFSD) const
+{
+    return new LogicalFontInstance(rFSD);
+}
+
 sal_Int32 PhysicalFontFace::CompareIgnoreSize( const PhysicalFontFace& rOther ) const
 {
     // compare their width, weight, italic, style name and family name
diff --git a/vcl/source/gdi/pdfwriter_impl.cxx b/vcl/source/gdi/pdfwriter_impl.cxx
index 9d541cf72235..4144d528f2fd 100644
--- a/vcl/source/gdi/pdfwriter_impl.cxx
+++ b/vcl/source/gdi/pdfwriter_impl.cxx
@@ -2231,13 +2231,6 @@ PdfBuiltinFontFace::PdfBuiltinFontFace( const PDFWriterImpl::BuiltinFont& rBuilt
     mrBuiltin( rBuiltin )
 {}
 
-LogicalFontInstance* PdfBuiltinFontFace::CreateFontInstance( const FontSelectPattern& rFSD ) const
-{
-    LogicalFontInstance* pEntry = new LogicalFontInstance( rFSD );
-    return pEntry;
-}
-
-
 void PDFWriterImpl::newPage( double nPageWidth, double nPageHeight, PDFWriter::Orientation eOrientation )
 {
     endPage();
diff --git a/vcl/source/gdi/pdfwriter_impl.hxx b/vcl/source/gdi/pdfwriter_impl.hxx
index cf8fe720050c..6fba738201cd 100644
--- a/vcl/source/gdi/pdfwriter_impl.hxx
+++ b/vcl/source/gdi/pdfwriter_impl.hxx
@@ -1300,7 +1300,6 @@ public:
     const PDFWriterImpl::BuiltinFont&   GetBuiltinFont() const  { return mrBuiltin; }
 
     virtual PhysicalFontFace*           Clone() const override { return new PdfBuiltinFontFace(*this); }
-    virtual LogicalFontInstance*        CreateFontInstance( const FontSelectPattern& ) const override;
     virtual sal_IntPtr                  GetFontId() const override { return reinterpret_cast<sal_IntPtr>(&mrBuiltin); }
 };
 
diff --git a/vcl/unx/generic/glyphs/freetype_glyphcache.cxx b/vcl/unx/generic/glyphs/freetype_glyphcache.cxx
index 5a55ee47bff3..fe1bb9391307 100644
--- a/vcl/unx/generic/glyphs/freetype_glyphcache.cxx
+++ b/vcl/unx/generic/glyphs/freetype_glyphcache.cxx
@@ -354,10 +354,9 @@ FreetypeFontFace::FreetypeFontFace( FreetypeFontInfo* pFI, const FontAttributes&
 {
 }
 
-LogicalFontInstance* FreetypeFontFace::CreateFontInstance( const FontSelectPattern& rFSD ) const
+LogicalFontInstance* FreetypeFontFace::CreateFontInstance(const FontSelectPattern& rFSD) const
 {
-    FreetypeFontInstance* pEntry = new FreetypeFontInstance( rFSD );
-    return pEntry;
+    return new FreetypeFontInstance(rFSD);
 }
 
 // FreetypeFont
diff --git a/vcl/unx/generic/print/genpspgraphics.cxx b/vcl/unx/generic/print/genpspgraphics.cxx
index 40004fac5bf0..7d52960f12b0 100644
--- a/vcl/unx/generic/print/genpspgraphics.cxx
+++ b/vcl/unx/generic/print/genpspgraphics.cxx
@@ -41,9 +41,9 @@
 #include <config_cairo_canvas.h>
 
 #include <fontsubset.hxx>
+#include <unx/freetype_glyphcache.hxx>
 #include <unx/geninst.h>
 #include <unx/genpspgraphics.h>
-#include <unx/glyphcache.hxx>
 #include <unx/printergfx.hxx>
 #include <impfont.hxx>
 #include <langboost.hxx>
@@ -523,7 +523,7 @@ void GenPspGraphics::invert(long,long,long,long,SalInvert)
     OSL_FAIL("Warning: PrinterGfx::Invert() not implemented");
 }
 
-class ImplPspFontData : public PhysicalFontFace
+class ImplPspFontData : public FreetypeFontFace
 {
 private:
     sal_IntPtr              mnFontId;
@@ -532,20 +532,13 @@ public:
     explicit ImplPspFontData( const psp::FastPrintFontInfo& );
     virtual sal_IntPtr      GetFontId() const override { return mnFontId; }
     virtual PhysicalFontFace*   Clone() const override { return new ImplPspFontData( *this ); }
-    virtual LogicalFontInstance*  CreateFontInstance( const FontSelectPattern& ) const override;
 };
 
-ImplPspFontData::ImplPspFontData( const psp::FastPrintFontInfo& rInfo )
-:   PhysicalFontFace( GenPspGraphics::Info2FontAttributes(rInfo) ),
+ImplPspFontData::ImplPspFontData(const psp::FastPrintFontInfo& rInfo)
+:   FreetypeFontFace(nullptr, GenPspGraphics::Info2FontAttributes(rInfo)),
     mnFontId( rInfo.m_nID )
 {}
 
-LogicalFontInstance* ImplPspFontData::CreateFontInstance( const FontSelectPattern& rFSD ) const
-{
-    FreetypeFontInstance* pEntry = new FreetypeFontInstance( rFSD );
-    return pEntry;
-}
-
 class PspCommonSalLayout : public CommonSalLayout
 {
 public:
diff --git a/vcl/win/gdi/winlayout.cxx b/vcl/win/gdi/winlayout.cxx
index 409b0b447986..2e56a96fa2dd 100644
--- a/vcl/win/gdi/winlayout.cxx
+++ b/vcl/win/gdi/winlayout.cxx
@@ -333,10 +333,9 @@ PhysicalFontFace* WinFontFace::Clone() const
     return pClone;
 }
 
-LogicalFontInstance* WinFontFace::CreateFontInstance( const FontSelectPattern& rFSD ) const
+LogicalFontInstance* WinFontFace::CreateFontInstance(const FontSelectPattern& rFSD) const
 {
-    LogicalFontInstance* pFontInstance = new WinFontInstance( rFSD );
-    return pFontInstance;
+    return new WinFontInstance(rFSD);
 }
 
 bool WinSalGraphics::CacheGlyphs(const CommonSalLayout& rLayout)


More information about the Libreoffice-commits mailing list