#include <fontimpl.h>
Public Member Functions | |
FontMetricsCacheEntry () | |
Default constructor. | |
BOOL | CacheFontMetrics (wxDC *pDC, CharDescription FontDesc, MILLIPOINT DefaultHeight, INT32 DesignSize) |
Refill the font cache entry. | |
void | CheckCharWidthsSameAsABCWidths (wxDC *pDC, CharDescription FontDesc) |
Test to see if GetCharWidth() with design size font is as accurate as GetCharABCWidths(). | |
INT32 | GetCharWidthFromCache (WCHAR ch) |
MILLIPOINT | GetFontEmWidth () |
MILLIPOINT | GetFontAscent () |
MILLIPOINT | GetFontDescent () |
CharDescription | GetFontDesc () |
void | SetFontEmWidth (MILLIPOINT NewFontEmWidth) |
void | SetFontAscent (MILLIPOINT NewFontAscent) |
void | SetFontDescent (MILLIPOINT NewFontDescent) |
void | SetFontDesc (CharDescription NewFontDesc) |
Static Public Member Functions | |
static BOOL | CharInCacheRange (WCHAR ch) |
Protected Types | |
enum | CharRange { FIRSTCHAR = 32, LASTCHAR = 127, NUMCHARS = (LASTCHAR-FIRSTCHAR+1) } |
Protected Attributes | |
MILLIPOINT | pCharWidths [NUMCHARS] |
MILLIPOINT | FontEmWidth |
MILLIPOINT | FontAscent |
MILLIPOINT | FontDescent |
CharDescription | FontDesc |
Private Member Functions | |
CC_DECLARE_MEMDUMP (FontMetricsCacheEntry) |
Definition at line 114 of file fontimpl.h.
|
Definition at line 141 of file fontimpl.h.
|
|
Default constructor.
Definition at line 890 of file fontbase.cpp. 00891 { 00892 for (INT32 i=0; i<NUMCHARS; i++) 00893 pCharWidths[i] = 0; 00894 00895 FontEmWidth = 0; 00896 FontAscent = 0; 00897 FontDescent = 0; 00898 CharDescription emptyCharDesc(0, 0, 0, 0); 00899 FontDesc = emptyCharDesc; 00900 }
|
|
Refill the font cache entry.
Definition at line 917 of file fontbase.cpp. 00919 { 00920 #ifdef __WXGTK__ 00921 INT32 Ascent; 00922 INT32 Descent; 00923 #endif 00924 00925 // these values are ignored - the DesignSize needs to be read from the font, so the 00926 // scaling needs to be done by FTFontMan itself 00927 IGNOREPARAM(DefaultHeight); 00928 IGNOREPARAM(DesignSize); 00929 00930 #ifdef __WXGTK__ 00931 // TRACEUSER("wuerthne", _T("CacheFontMetrics DesignSize = %d"), DesignSize); 00932 if (FTFontMan::GetAscentDescent(FontDesc, &Ascent, &Descent) == FALSE) return FALSE; 00933 // scaling to DefaultHeight was done in GetAscentDescent already 00934 SetFontAscent( Ascent ); 00935 SetFontDescent( -Descent ); 00936 00937 // get char widths and convert form design size in pixels to default height in millipoints 00938 static INT32 pTempCharWidthBuf[NUMCHARS]; 00939 if (FTFontMan::GetCharWidth(FontDesc, FIRSTCHAR, LASTCHAR, pTempCharWidthBuf)==FALSE) 00940 return FALSE; 00941 // scaling to DefaultHeight was done in GetCharWidth already 00942 for (INT32 i=0; i<NUMCHARS; i++) 00943 pCharWidths[i] = pTempCharWidthBuf[i]; 00944 00945 // if 'em' char in cache, get it from the cache else calculate its width separately 00946 if (CharInCacheRange(FONTEMCHAR)) 00947 SetFontEmWidth( GetCharWidthFromCache(FONTEMCHAR) ); 00948 else 00949 { 00950 ERROR3("FontMetricsCache::GetCharMetrics() - 'FONTEMCHAR' not in cache!"); 00951 INT32 TempCharWidth = 0; 00952 if (FTFontMan::GetCharWidth(FontDesc, FONTEMCHAR, FONTEMCHAR, &TempCharWidth)==FALSE) 00953 return FALSE; 00954 // scaling to DefaultHeight was done in GetCharWidth already 00955 SetFontEmWidth( TempCharWidth ); 00956 } 00957 00958 // update cache tag 00959 SetFontDesc(FontDesc); 00960 #else // !wxGTK 00961 return FALSE; 00962 #endif 00963 00964 #ifndef EXCLUDE_FROM_XARALX 00965 // debug test 00966 CheckCharWidthsSameAsABCWidths(pDC,FontDesc); 00967 #endif 00968 return TRUE; 00969 }
|
|
|
|
Definition at line 125 of file fontimpl.h.
|
|
Test to see if GetCharWidth() with design size font is as accurate as GetCharABCWidths().
Definition at line 982 of file fontbase.cpp. 00983 { 00984 #ifdef _DEBUG 00985 #ifndef EXCLUDE_FROM_XARALX 00986 // ensure that the char widths are the same as the sum of the ABC widths 00987 00988 // do nothing if its an ATM font (or an error) 00989 CachedFontItem* pItem = FONTMANAGER->GetFont(FontDesc.GetTypefaceHandle()); 00990 if (pItem->GetFontClass()==FC_ATM || pItem==NULL || pItem->IsCorrupt()) 00991 return; 00992 00993 INT32 pTempCharWidthBuf[NUMCHARS]; 00994 ABC pTempCharABCBuf[NUMCHARS]; 00995 BOOL ok = TextManager::GetCharWidth( pDC, FIRSTCHAR, LASTCHAR, pTempCharWidthBuf); 00996 if (ok) ok = TextManager::GetCharABCWidths(pDC, FIRSTCHAR, LASTCHAR, pTempCharABCBuf); 00997 ERROR3IF(!ok,"FontMetricsCache::CheckCharWidthsSameAsABCWidths() - TextManager::GetCharWidth()/GetCharABCWidths() failed!\n"); 00998 00999 for (INT32 i=0; i<NUMCHARS; i++) 01000 { 01001 ABC* pABC = &pTempCharABCBuf[i]; 01002 INT32 SumABC = pABC->abcA+pABC->abcB+pABC->abcC; 01003 INT32 CharWidth = pTempCharWidthBuf[i]; 01004 ERROR3IF_PF(SumABC!=CharWidth,("FontMetricsCache::CheckCharWidthsSameAsABCWidths() - sum of ABCwidths (%d) differs from CharWidths (%d)",SumABC,CharWidth)); 01005 } 01006 #endif 01007 01008 //#ifdef _DEBUG 01009 #if 0 01010 // test accuracy of old and new methods of calculating metrics 01011 01012 INT32 DesignSizeInPixels = TextManager::GetDesignSize(pDC); 01013 INT32 DefaultSizeInMP = TextManager::GetDefaultHeight(); 01014 INT32 dpi = pDC->GetDeviceCaps(LOGPIXELSY); 01015 for (MILLIPOINT FontSizeInMP=4000; FontSizeInMP<=72000; FontSizeInMP+=4000) 01016 { 01017 double SumNewMetrics = 0; 01018 double SumOldMetrics = 0; 01019 double SumAccurateMetrics = 0; 01020 for (WCHAR ch=0; ch<256; ch++) 01021 { 01022 INT32 DesignSizeMetricInPixels = 500; 01023 BOOL ok = TextManager::GetCharWidth(pDC,ch,ch,&DesignSizeMetricInPixels); 01024 ERROR3IF(!ok,"FontMetricsCache::CheckCharWidthsSameAsABCWidths() - TextManager::GetCharWidth() failed!\n"); 01025 01026 // new calc 01027 MILLIPOINT InchMetricInMP = MulDiv(DesignSizeMetricInPixels, DefaultSizeInMP, DesignSizeInPixels); 01028 FIXED16 InchMetricToFontSizeMetricRatio = Div32By32(FontSizeInMP, DefaultSizeInMP); 01029 MILLIPOINT NewFontSizeMetricInMP = InchMetricInMP * InchMetricToFontSizeMetricRatio; 01030 SumNewMetrics += NewFontSizeMetricInMP; 01031 01032 // old calc 01033 MILLIPOINT DesignSizeMetricInMP = MulDiv(DesignSizeMetricInPixels, 72000, dpi); 01034 MILLIPOINT DesignSizeInMP = MulDiv(DesignSizeInPixels, 72000, dpi); 01035 FIXED16 DesignSizeMetricToFontSizeMetricRatio = Div32By32(FontSizeInMP, DesignSizeInMP); 01036 MILLIPOINT OldFontSizeMetricInMP = DesignSizeMetricInMP * DesignSizeMetricToFontSizeMetricRatio; 01037 SumOldMetrics += OldFontSizeMetricInMP; 01038 01039 // accurate calc 01040 double AccurateFontSizeMetricInMP = (double) DesignSizeMetricInPixels / DesignSizeInPixels * FontSizeInMP; 01041 SumAccurateMetrics += AccurateFontSizeMetricInMP; 01042 } 01043 TRACEUSER( "Ed", _T("Sum of CharWidths (%5dMP): new=%8.0f (e=%6.2f), old=%8.0f (e=%6.2f), accrutate=%8.2f\n"), FontSizeInMP, SumNewMetrics, SumNewMetrics-SumAccurateMetrics, SumOldMetrics, SumOldMetrics-SumAccurateMetrics, SumAccurateMetrics); 01044 } 01045 #endif // EXCLUDE_FROM_XARALX 01046 #endif // _DEBUG 01047 }
|
|
Definition at line 127 of file fontimpl.h. 00127 { return pCharWidths[ch-FIRSTCHAR]; }
|
|
Definition at line 130 of file fontimpl.h. 00130 { return FontAscent; }
|
|
Definition at line 132 of file fontimpl.h. 00132 { return FontDesc; }
|
|
Definition at line 131 of file fontimpl.h. 00131 { return FontDescent; }
|
|
Definition at line 129 of file fontimpl.h. 00129 { return FontEmWidth; }
|
|
Definition at line 135 of file fontimpl.h. 00135 { FontAscent = NewFontAscent; }
|
|
Definition at line 137 of file fontimpl.h. 00137 { FontDesc = NewFontDesc; }
|
|
Definition at line 136 of file fontimpl.h. 00136 { FontDescent = NewFontDescent; }
|
|
Definition at line 134 of file fontimpl.h. 00134 { FontEmWidth = NewFontEmWidth; }
|
|
Definition at line 145 of file fontimpl.h. |
|
Definition at line 147 of file fontimpl.h. |
|
Definition at line 146 of file fontimpl.h. |
|
Definition at line 144 of file fontimpl.h. |
|
Definition at line 143 of file fontimpl.h. |