FontKerningPairsCacheEntry Class Reference

Holds a cache of kerning pairs for a font. More...

#include <fontimpl.h>

List of all members.

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 &)
FontKerningPairsCacheEntryoperator= (const FontKerningPairsCacheEntry &)


Detailed Description

Holds a cache of kerning pairs for a font.

Author:
Jonathan_Payne (Xara Group Ltd) <camelotdev@xara.com>
Date:
16/10/2000

Definition at line 213 of file fontimpl.h.


Constructor & Destructor Documentation

FontKerningPairsCacheEntry::FontKerningPairsCacheEntry  ) 
 

Default constructor.

Author:
Martin Wuerthner <xara@mw-software.com>
Date:
20/04/2006

Definition at line 1226 of file fontbase.cpp.

01227 {
01228     CharDescription emptyCharDesc(0, 0, 0, 0);
01229     FontDesc = emptyCharDesc;
01230     m_pPairsCacheMap = NULL;
01231 }

FontKerningPairsCacheEntry::~FontKerningPairsCacheEntry  ) 
 

Destructor.

Author:
Martin Wuerthner <xara@mw-software.com>
Date:
20/04/2006

Definition at line 1241 of file fontbase.cpp.

01242 {
01243     if (m_pPairsCacheMap) delete m_pPairsCacheMap;
01244 }

FontKerningPairsCacheEntry::FontKerningPairsCacheEntry const FontKerningPairsCacheEntry  )  [private]
 


Member Function Documentation

FontKerningPairsCacheEntry::CC_DECLARE_MEMDUMP FontKerningPairsCacheEntry   )  [private]
 

MILLIPOINT FontKerningPairsCacheEntry::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.

Author:
Martin Wuerthner <xara@mw-software.com>
Date:
20/04/2006
Parameters:
chLeft = a character code of the left char of a kerning pair [INPUTS] chRight = a character code of the right char of a kerning pair
Returns:
Kern in millipoints (or zero if no kern or error)

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 }

CharDescription FontKerningPairsCacheEntry::GetFontDesc  )  [inline]
 

Definition at line 224 of file fontimpl.h.

00224 { return FontDesc; }

FontKerningPairsCacheEntry& FontKerningPairsCacheEntry::operator= const FontKerningPairsCacheEntry  )  [private]
 

void FontKerningPairsCacheEntry::Reinitialise CharDescription NewFontDesc  ) 
 

Clears the cache entry and initialises it for a new font.

Author:
Martin Wuerthner <xara@mw-software.com>
Date:
20/04/2006
Parameters:
NewFontDesc = a font descriptor specifying the font to which this cache [INPUTS] entry should refer from now on

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 }

void FontKerningPairsCacheEntry::SetFontDesc CharDescription  NewFontDesc  )  [inline]
 

Definition at line 225 of file fontimpl.h.

00225 { FontDesc = NewFontDesc; }


Member Data Documentation

CharDescription FontKerningPairsCacheEntry::FontDesc [protected]
 

Definition at line 233 of file fontimpl.h.

std::map<UINT32,INT32>* FontKerningPairsCacheEntry::m_pPairsCacheMap [protected]
 

Definition at line 236 of file fontimpl.h.


The documentation for this class was generated from the following files:
Generated on Sat Nov 10 03:54:29 2007 for Camelot by  doxygen 1.4.4