summaryrefslogtreecommitdiff
path: root/vcl/inc
diff options
context:
space:
mode:
authorJan-Marek Glogowski <glogow@fbihome.de>2017-12-14 18:42:57 +0100
committerJan-Marek Glogowski <glogow@fbihome.de>2017-12-15 11:13:22 +0100
commit8b700794b2746070814e9ff416ecd7bbb1c902e7 (patch)
tree33f7d4601405d518ebd476b69122d092c01d8219 /vcl/inc
parent2ba36f21bad74cbbd68611afddaf9bbdc8ffda50 (diff)
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@libreoffice.org> Reviewed-by: Jan-Marek Glogowski <glogow@fbihome.de>
Diffstat (limited to 'vcl/inc')
-rw-r--r--vcl/inc/PhysicalFontFace.hxx31
-rw-r--r--vcl/inc/fontinstance.hxx14
-rw-r--r--vcl/inc/quartz/salgdi.h1
-rw-r--r--vcl/inc/unx/freetype_glyphcache.hxx17
-rw-r--r--vcl/inc/unx/glyphcache.hxx15
-rw-r--r--vcl/inc/win/winlayout.hxx17
6 files changed, 44 insertions, 51 deletions
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