summaryrefslogtreecommitdiff
path: root/Build/source/libs/graphite/engine-2.3.1/src/segment/FontCache.h
diff options
context:
space:
mode:
authorPeter Breitenlohner <peb@mppmu.mpg.de>2009-11-10 10:18:38 +0000
committerPeter Breitenlohner <peb@mppmu.mpg.de>2009-11-10 10:18:38 +0000
commit9ab1d67ae5be915e0a7e146123ea577b8b7d85cf (patch)
tree02180daeded681369095ccb9e1f592502d032c90 /Build/source/libs/graphite/engine-2.3.1/src/segment/FontCache.h
parentc9e6fa742a274dd314b6e483c65a810f7ed44d1e (diff)
towards TL2010: libs graphite
git-svn-id: svn://tug.org/texlive/trunk@15953 c570f23f-e606-0410-a88d-b1316a301751
Diffstat (limited to 'Build/source/libs/graphite/engine-2.3.1/src/segment/FontCache.h')
-rw-r--r--Build/source/libs/graphite/engine-2.3.1/src/segment/FontCache.h105
1 files changed, 105 insertions, 0 deletions
diff --git a/Build/source/libs/graphite/engine-2.3.1/src/segment/FontCache.h b/Build/source/libs/graphite/engine-2.3.1/src/segment/FontCache.h
new file mode 100644
index 00000000000..56da5ab26b8
--- /dev/null
+++ b/Build/source/libs/graphite/engine-2.3.1/src/segment/FontCache.h
@@ -0,0 +1,105 @@
+/*--------------------------------------------------------------------*//*:Ignore this sentence.
+Copyright (C) 1999, 2001 SIL International. All rights reserved.
+
+Distributable under the terms of either the Common Public License or the
+GNU Lesser General Public License, as specified in the LICENSING.txt file.
+
+File: FontCache.h
+Responsibility: Sharon Correll
+Last reviewed: Not yet.
+
+Description:
+ A cache of all the font-face objects known to mankind. There is exactly one instance
+ of a FontCache.
+----------------------------------------------------------------------------------------------*/
+#ifdef _MSC_VER
+#pragma once
+#endif
+#ifndef FONTCACHE_INCLUDED
+#define FONTCACHE_INCLUDED
+
+//:End Ignore
+
+namespace gr
+{
+
+class FontFace;
+class FontMemoryUsage;
+
+/*----------------------------------------------------------------------------------------------
+ TODO: change from a sorted list to a hash table, if performance so requires.
+----------------------------------------------------------------------------------------------*/
+class FontCache {
+ friend class FontMemoryUsage;
+
+public:
+ FontCache()
+ {
+ m_cfci = 0;
+ m_prgfci = NULL;
+ m_cfciMax = 0;
+ m_cfface = 0;
+ m_flush = kflushAuto;
+ }
+
+ ~FontCache()
+ {
+ delete[] m_prgfci;
+ m_prgfci = NULL;
+ m_cfci = 0;
+ m_cfciMax = 0;
+ m_cfface = 0;
+ }
+
+ void Initialize()
+ {
+ m_cfci = 0;
+ m_prgfci = new CacheItem[12];
+ m_cfciMax = 12;
+ m_cfface = 0;
+ }
+
+ struct CacheItem
+ {
+ wchar_t szFaceName[32]; // type should match std::wstring
+ FontFace * pffaceRegular;
+ FontFace * pffaceBold;
+ FontFace * pffaceItalic;
+ FontFace * pffaceBI;
+ };
+
+ void GetFontFace(std::wstring strFaceName, bool fBold, bool fItalic, FontFace ** ppfface);
+ void CacheFontFace(std::wstring strFaceName, bool fBold, bool fItalic, FontFace * pfface);
+ bool RemoveFontFace(std::wstring strFaceName, bool fBold, bool fItalic, bool fZapCache = true);
+ void DeleteIfEmpty();
+ void AssertEmpty();
+
+ int GetFlushMode()
+ {
+ return m_flush;
+ }
+ void SetFlushMode(int);
+
+ // Debugging:
+ //bool DbgCheckFontCache();
+
+ void calculateMemoryUsage(FontMemoryUsage & fmu);
+
+protected:
+ int FindCacheItem(std::wstring strFaceName);
+ void InsertCacheItem(int ifci);
+
+protected:
+ // member variables;
+ int m_cfci; // number of items (font-families)
+ int m_cfciMax; // amount of space available
+ int m_cfface; // number of font-faces
+ CacheItem * m_prgfci;
+
+ int m_flush;
+};
+
+} // namespace gr
+
+
+#endif // !FONTCACHE_INCLUDED