Updates for new XPCOM interface changes to the font metrics

This commit is contained in:
spider%netscape.com 1998-08-31 20:11:08 +00:00
parent 25f0cc2f12
commit 89e25f98f6
2 changed files with 41 additions and 26 deletions

View File

@ -43,18 +43,21 @@ public:
NS_DECL_ISUPPORTS
NS_IMETHOD Init(const nsFont& aFont, nsIDeviceContext* aContext);
NS_IMETHOD GetWidth(char aC);
NS_IMETHOD GetWidth(PRUnichar aC);
NS_IMETHOD GetWidth(const nsString& aString);
NS_IMETHOD GetWidth(const char *aString);
NS_IMETHOD GetWidth(const PRUnichar *aString, PRUint32 aLength);
NS_IMETHOD GetWidth(nsIDeviceContext *aContext, const nsString& aString);
NS_IMETHOD GetHeight();
NS_IMETHOD GetLeading();
NS_IMETHOD GetMaxAscent();
NS_IMETHOD GetMaxDescent();
NS_IMETHOD GetMaxAdvance();
NS_IMETHOD nscoord *GetWidths(const nscoord *&aWidths);
NS_IMETHOD GetWidth(char aC, nscoord &aWidth);
NS_IMETHOD GetWidth(PRUnichar aC, nscoord &aWidth);
NS_IMETHOD GetWidth(const nsString& aString, nscoord &aWidth);
NS_IMETHOD GetWidth(const char *aString, nscoord &aWidth);
NS_IMETHOD GetWidth(const PRUnichar *aString, PRUint32 aLength, nscoord &aWidth);
NS_IMETHOD GetWidth(nsIDeviceContext *aContext, const nsString& aString, nscoord &aWidth);
NS_IMETHOD GetHeight(nscoord &aHeight);
NS_IMETHOD GetLeading(nscoord &aLeading);
NS_IMETHOD GetMaxAscent(nscoord &aAscent);
NS_IMETHOD GetMaxDescent(nscoord &aDescent);
NS_IMETHOD GetMaxAdvance(nscoord &aAdvance);
NS_IMETHOD GetWidths(const nscoord *&aWidths);
NS_IMETHOD GetFont(const nsFont*& aFont);
NS_IMETHOD GetFontHandle(nsFontHandle &aHandle);

View File

@ -939,12 +939,14 @@ void nsRenderingContextUnix :: DrawString(const char *aString, PRUint32 aLength,
nscoord aX, nscoord aY,
nscoord aWidth)
{
PRInt32 x = aX;
PRInt32 y = aY;
nscoord x = aX;
nscoord y = aY;
// Substract xFontStruct ascent since drawing specifies baseline
if (mFontMetrics)
y += mFontMetrics->GetMaxAscent();
if (mFontMetrics) {
mFontMetrics->GetMaxAscent(y);
y+=aY;
}
mTMatrix->TransformCoord(&x,&y);
@ -962,8 +964,10 @@ void nsRenderingContextUnix :: DrawString(const char *aString, PRUint32 aLength,
if (deco & NS_FONT_DECORATION_UNDERLINE)
{
nscoord ascent = mFontMetrics->GetMaxAscent();
nscoord descent = mFontMetrics->GetMaxDescent();
nscoord ascent,descent;
mFontMetrics->GetMaxAscent(ascent);
mFontMetrics->GetMaxDescent(descent);
DrawLine(aX, aY + ascent + (descent >> 1),
aX + aWidth, aY + ascent + (descent >> 1));
@ -971,7 +975,9 @@ void nsRenderingContextUnix :: DrawString(const char *aString, PRUint32 aLength,
if (deco & NS_FONT_DECORATION_LINE_THROUGH)
{
nscoord height = mFontMetrics->GetHeight();
nscoord height;
mFontMetrics->GetHeight(height);
DrawLine(aX, aY + (height >> 1), aX + aWidth, aY + (height >> 1));
}
@ -981,12 +987,14 @@ void nsRenderingContextUnix :: DrawString(const char *aString, PRUint32 aLength,
void nsRenderingContextUnix :: DrawString(const PRUnichar *aString, PRUint32 aLength,
nscoord aX, nscoord aY, nscoord aWidth)
{
PRInt32 x = aX;
PRInt32 y = aY;
nscoord x = aX;
nscoord y = aY;
// Substract xFontStruct ascent since drawing specifies baseline
if (mFontMetrics)
y += mFontMetrics->GetMaxAscent();
if (mFontMetrics) {
mFontMetrics->GetMaxAscent(y);
y+=aY;
}
mTMatrix->TransformCoord(&x, &y);
@ -1004,8 +1012,10 @@ void nsRenderingContextUnix :: DrawString(const PRUnichar *aString, PRUint32 aLe
if (deco & NS_FONT_DECORATION_UNDERLINE)
{
nscoord ascent = mFontMetrics->GetMaxAscent();
nscoord descent = mFontMetrics->GetMaxDescent();
nscoord ascent,descent;
mFontMetrics->GetMaxAscent(ascent);
mFontMetrics->GetMaxDescent(descent);
DrawLine(aX, aY + ascent + (descent >> 1),
aX + aWidth, aY + ascent + (descent >> 1));
@ -1013,7 +1023,9 @@ void nsRenderingContextUnix :: DrawString(const PRUnichar *aString, PRUint32 aLe
if (deco & NS_FONT_DECORATION_LINE_THROUGH)
{
nscoord height = mFontMetrics->GetHeight();
nscoord height;
mFontMetrics->GetHeight(height);
DrawLine(aX, aY + (height >> 1), aX + aWidth, aY + (height >> 1));
}