6 #if !defined(LST_FONTCACHE_H__INCLUDED_)
7 #define LST_FONTCACHE_H__INCLUDED_
15 #include "FontProperties.h"
16 #include "FontCacheEntry.h"
17 #include "Utility/LSTException.h"
18 #include "Utility/Config.h"
19 #include "Utility/wstring.h"
22 #include FT_FREETYPE_H
26 static const wchar_t *cvFonts = L
"SOFTWARE\\Microsoft\\Windows NT\\CurrentVersion\\Fonts";
27 static const wchar_t *cvT1fonts = L
"SOFTWARE\\Microsoft\\Windows NT\\CurrentVersion\\Type 1 Installer\\Type 1 Fonts";
28 static const wchar_t *lstFontCacheDir = L
"\\Larson Software Technology\\Common";
29 static const wchar_t *lstFontCacheFile = L
"\\FontCache.dat";
30 static const wchar_t *baseFontPath = L
"";
35 static const wchar_t *cvFonts = L
"";
36 static const wchar_t *cvT1fonts = L
"";
37 static const wchar_t *lstFontCacheDir = L
"/common";
38 static const wchar_t *lstFontCacheFile = L
"/FontCache.dat";
39 static const wchar_t *baseFontPath = L
"~/.larson/common/fonts;/usr/local/lib/larson/fonts;/usr/local/lib64/larson/fonts;~/.fonts;/usr/share/fonts;/usr/share/X11/fonts";
44 static const wchar_t *cvFonts = L
"";
45 static const wchar_t *cvT1fonts = L
"";
46 static const wchar_t *lstFontCacheDir = L
"/";
47 static const wchar_t *lstFontCacheFile = L
"/FontCache.dat";
48 static const wchar_t *baseFontPath = L
"/fonts";
53 static const wchar_t *cvFonts = L
"";
54 static const wchar_t *cvT1fonts = L
"";
55 static const wchar_t *lstFontCacheDir = L
"/Larson Software Technology/Common";
56 static const wchar_t *lstFontCacheFile = L
"/FontCache.dat";
59 static const wchar_t *baseFontPath = L
"/System/Library/Fonts;/System/Library/Fonts/Cache;/System/Library/Fonts/Core";
64 static const wchar_t *cvFonts = L
"";
65 static const wchar_t *cvT1fonts = L
"";
66 static const wchar_t *lstFontCacheDir = L
"";
67 static const wchar_t *lstFontCacheFile = L
"/FontCache.dat";
68 static const wchar_t *baseFontPath = L
"/system/fonts";
81 std::wstring* matchName;
85 typedef multimap <wchar_t, MapEntry, less<wchar_t> > cache_type;
96 eUnableToInitializeFreeType = EXC_FONTCACHE,
97 eUnableToGenerateFontCache = EXC_FONTCACHE + 1,
98 eUnableToWriteFontCacheFile = EXC_FONTCACHE + 2,
99 eUnableToOpenFontCacheFile = EXC_FONTCACHE + 3
102 typedef cache_type::value_type value_type;
109 void restore(Larson::CConfig* config);
111 FT_Face findFace(Larson::CConfig* config,
CLSTFont *);
112 int getFacesSize() {
return (
int)m_fontEntries.size(); };
113 std::wstring getFaceFamilyByIndex(
int index) {
return m_fontEntries[index].m_familyName; };
114 std::wstring getFacePathByIndex(
int index) {
return m_fontEntries[index].m_path; };
119 keys[0] = (
wchar_t*)cvFonts;
120 keys[1] = (
wchar_t*)cvT1fonts;
122 m_cacheLoaded =
false;
124 m_diskCacheOld =
false;
125 m_version = LST_CACHE_VERSION;
131 FT_Error newFace(std::string path,
int faceIndex, FT_Face *face);
132 FT_Face loadFace(CFontCacheEntry* entry);
133 FT_Face matchSubstituteFont(
const std::wstring &subName);
134 CFontCacheEntry* matchByProps(CFontProperties& props);
135 CFontCacheEntry::Weight type1WeightStringToValue(
string weight);
136 FT_Face trySubstitution(vector<std::wstring> substitutes);
138 void addFaceToFaceVector(FT_Face face, std::wstring path);
139 void organizeNamesInCache();
140 bool diskCacheExists();
141 unsigned long getFontCheckValue(Larson::CConfig* config);
143 void generateCache(Larson::CConfig* config);
144 inline int nEquals(std::wstring str1, std::wstring str2)
147 for (; i < (int)str1.size() && i < (int)str2.size(); i++)
149 if (str1[i] != str2[i])
155 FT_Library m_library;
157 vector<CFontCacheEntry> m_fontEntries;
159 unsigned long m_checkvalue;
160 unsigned long m_version;
162 std::wstring m_fontCachePath;
164 static void Destroy() {
168 static bool m_cacheLoaded;
169 static CFontCache* m_pInstance;
170 static MUTEX m_mutex;
174 #endif // LST_FONTCACHE_H__INCLUDED_
CFontCache – generates and maintains font cache.
Definition: FontCache.h:89
ExceptionCodes
A container for all the available system fonts.
Definition: FontCache.h:95
bool m_unicodeName
is unicode name
Definition: FontCache.h:77
CLSTFont – Font object class, one per facename used in a CGM picture.
Definition: Font.h:28
FontCache map entry.
Definition: FontCache.h:75
CFontCacheEntry – defines the data in a font cache entry.
Definition: FontCacheEntry.h:20