Added GetAveCharWidth() function

This commit is contained in:
troy%netscape.com 2000-03-29 01:26:08 +00:00
parent 8dc180f736
commit 4e2ec77d3b
3 changed files with 17 additions and 1 deletions

View File

@ -154,6 +154,13 @@ public:
* Returns the font handle associated with these metrics
*/
NS_IMETHOD GetFontHandle(nsFontHandle &aHandle) = 0;
#ifdef _WIN32
/**
* Returns the average character width
*/
NS_IMETHOD GetAveCharWidth(nscoord& aAveCharWidth) = 0;
#endif
};
#endif /* nsIFontMetrics_h___ */

View File

@ -2524,6 +2524,7 @@ HDC dc1 = NULL;
mMaxAscent = NSToCoordRound(metrics.tmAscent * dev2app);
mMaxDescent = NSToCoordRound(metrics.tmDescent * dev2app);
mMaxAdvance = NSToCoordRound(metrics.tmMaxCharWidth * dev2app);
mAveCharWidth = NSToCoordRound(metrics.tmAveCharWidth * dev2app);
// Cache the width of a single space.
SIZE size;
@ -2647,6 +2648,13 @@ nsFontMetricsWin::GetFontHandle(nsFontHandle &aHandle)
return NS_OK;
}
NS_IMETHODIMP
nsFontMetricsWin::GetAveCharWidth(nscoord &aAveCharWidth)
{
aAveCharWidth = mAveCharWidth;
return NS_OK;
}
nsFontWin::nsFontWin(LOGFONT* aLogFont, HFONT aFont, PRUint32* aMap)
{
if (aLogFont) {
@ -2678,7 +2686,6 @@ nsFontWinUnicode::GetWidth(HDC aDC, const PRUnichar* aString, PRUint32 aLength)
{
SIZE size;
::GetTextExtentPoint32W(aDC, aString, aLength, &size);
return size.cx;
}

View File

@ -123,6 +123,7 @@ public:
NS_IMETHOD GetFont(const nsFont *&aFont);
NS_IMETHOD GetLangGroup(nsIAtom** aLangGroup);
NS_IMETHOD GetFontHandle(nsFontHandle &aHandle);
NS_IMETHOD GetAveCharWidth(nscoord &aAveCharWidth);
virtual nsresult GetSpaceWidth(nscoord &aSpaceWidth);
virtual nsFontWin* FindGlobalFont(HDC aDC, PRUnichar aChar);
@ -199,6 +200,7 @@ protected:
nscoord mMaxAscent;
nscoord mMaxDescent;
nscoord mMaxAdvance;
nscoord mAveCharWidth;
#ifdef MOZ_MATHML
float mItalicSlope;
#endif