#include <fontimpl.h>
Public Member Functions | |
FontKerningPairsCacheEntry () | |
Default constructor. | |
~FontKerningPairsCacheEntry () | |
Destructor. | |
void | Reinitialise (CharDescription &NewFontDesc) |
Clears the cache entry and initialises it for a new font. | |
MILLIPOINT | GetCharsKerning (WCHAR chLeft, WCHAR chRight) |
Gets the kerning for a character pair (and caches it if not cached yet) Note: The cache uses an STL map, which means logarithmic access time. Maybe a hash_map could do better. | |
CharDescription | GetFontDesc () |
void | SetFontDesc (CharDescription NewFontDesc) |
Protected Attributes | |
CharDescription | FontDesc |
std::map< UINT32, INT32 > * | m_pPairsCacheMap |
Private Member Functions | |
CC_DECLARE_MEMDUMP (FontKerningPairsCacheEntry) | |
FontKerningPairsCacheEntry (const FontKerningPairsCacheEntry &) | |
FontKerningPairsCacheEntry & | operator= (const FontKerningPairsCacheEntry &) |
Definition at line 213 of file fontimpl.h.
|
Default constructor.
Definition at line 1226 of file fontbase.cpp. 01227 { 01228 CharDescription emptyCharDesc(0, 0, 0, 0); 01229 FontDesc = emptyCharDesc; 01230 m_pPairsCacheMap = NULL; 01231 }
|
|
Destructor.
Definition at line 1241 of file fontbase.cpp. 01242 { 01243 if (m_pPairsCacheMap) delete m_pPairsCacheMap; 01244 }
|
|
|
|
|
|
Gets the kerning for a character pair (and caches it if not cached yet) Note: The cache uses an STL map, which means logarithmic access time. Maybe a hash_map could do better.
Definition at line 1278 of file fontbase.cpp. 01279 { 01280 UINT32 key; 01281 // we cache the kerning for characters in the range 0x0 - 0xFFFF only 01282 // we also need the map set up - if it could not be allocated, we simply bypass the cache 01283 if (chLeft > 0x10000 || chRight > 0x10000 || m_pPairsCacheMap == NULL) 01284 { 01285 // TRACEUSER("wuerthne", _T("Bypass cache")); 01286 #ifdef __WXGTK__ 01287 return FTFontMan::GetCharsKerning(FontDesc, chLeft, chRight); 01288 #else 01289 return 0; 01290 #endif 01291 } 01292 01293 key = (chLeft << 16) | chRight; 01294 std::map<UINT32,INT32>::iterator it = m_pPairsCacheMap->find(key); 01295 if (it != m_pPairsCacheMap->end()) { 01296 // we found a cached entry 01297 // TRACEUSER("wuerthne", _T("kern pair found")); 01298 return it->second; 01299 } 01300 else { 01301 // we did not find an entry, so get the kerning from the underlying font system 01302 #ifdef __WXGTK__ 01303 INT32 kerning = FTFontMan::GetCharsKerning(FontDesc, chLeft, chRight); 01304 #else 01305 INT32 kerning = 0; 01306 #endif 01307 // and cache it 01308 // TRACEUSER("wuerthne", _T("cache kern pair")); 01309 (*m_pPairsCacheMap)[key] = kerning; 01310 return kerning; 01311 } 01312 }
|
|
Definition at line 224 of file fontimpl.h. 00224 { return FontDesc; }
|
|
|
|
Clears the cache entry and initialises it for a new font.
Definition at line 1256 of file fontbase.cpp. 01257 { 01258 FontDesc = NewFontDesc; 01259 if (m_pPairsCacheMap) delete m_pPairsCacheMap; 01260 m_pPairsCacheMap = new std::map<UINT32,INT32>; 01261 // we do not check whether the new has succeeded - in case it has not, 01262 // we will not fall over later but caching will be disabled for this entry 01263 }
|
|
Definition at line 225 of file fontimpl.h. 00225 { FontDesc = NewFontDesc; }
|
|
Definition at line 233 of file fontimpl.h. |
|
Definition at line 236 of file fontimpl.h. |