зеркало из https://github.com/mozilla/pjs.git
port performance enhancements from gtk fonts
This commit is contained in:
Родитель
ab7d0a1f39
Коммит
d46a7df85f
|
@ -62,6 +62,7 @@ nsFontMetricsXlib::nsFontMetricsXlib()
|
||||||
mStrikeoutOffset = 0;
|
mStrikeoutOffset = 0;
|
||||||
mUnderlineSize = 0;
|
mUnderlineSize = 0;
|
||||||
mUnderlineOffset = 0;
|
mUnderlineOffset = 0;
|
||||||
|
mSpaceWidth = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
nsFontMetricsXlib::~nsFontMetricsXlib()
|
nsFontMetricsXlib::~nsFontMetricsXlib()
|
||||||
|
@ -419,6 +420,8 @@ void nsFontMetricsXlib::RealizeFont()
|
||||||
// 56% of ascent, best guess for non-true type
|
// 56% of ascent, best guess for non-true type
|
||||||
mXHeight = NSToCoordRound((float) mFontHandle->ascent* f * 0.56f);
|
mXHeight = NSToCoordRound((float) mFontHandle->ascent* f * 0.56f);
|
||||||
|
|
||||||
|
int rawWidth = XTextWidth(mFontHandle, " ", 1);
|
||||||
|
mSpaceWidth = NSToCoordRound(rawWidth * f);
|
||||||
unsigned long pr = 0;
|
unsigned long pr = 0;
|
||||||
|
|
||||||
if (::XGetFontProperty(mFontHandle, XA_X_HEIGHT, &pr))
|
if (::XGetFontProperty(mFontHandle, XA_X_HEIGHT, &pr))
|
||||||
|
@ -2184,4 +2187,11 @@ nsFontMetricsXlib::DrawString(nsDrawingSurfaceXlib* aSurface, nsFontXlib* aFont,
|
||||||
aX, aY, buf, (len / 2));
|
aX, aY, buf, (len / 2));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
nsresult
|
||||||
|
nsFontMetricsXlib::GetSpaceWidth(nscoord &aSpaceWidth)
|
||||||
|
{
|
||||||
|
aSpaceWidth = mSpaceWidth;
|
||||||
|
return NS_OK;
|
||||||
|
}
|
||||||
|
|
||||||
#endif /* FONT_SWITCHING */
|
#endif /* FONT_SWITCHING */
|
||||||
|
|
|
@ -102,6 +102,8 @@ public:
|
||||||
NS_IMETHOD GetFont(const nsFont *&aFont);
|
NS_IMETHOD GetFont(const nsFont *&aFont);
|
||||||
NS_IMETHOD GetFontHandle(nsFontHandle &aHandle);
|
NS_IMETHOD GetFontHandle(nsFontHandle &aHandle);
|
||||||
|
|
||||||
|
virtual nsresult GetSpaceWidth(nscoord &aSpaceWidth);
|
||||||
|
|
||||||
#ifdef FONT_SWITCHING
|
#ifdef FONT_SWITCHING
|
||||||
|
|
||||||
nsFontXlib* FindFont(PRUnichar aChar);
|
nsFontXlib* FindFont(PRUnichar aChar);
|
||||||
|
@ -152,6 +154,7 @@ protected:
|
||||||
nscoord mStrikeoutOffset;
|
nscoord mStrikeoutOffset;
|
||||||
nscoord mUnderlineSize;
|
nscoord mUnderlineSize;
|
||||||
nscoord mUnderlineOffset;
|
nscoord mUnderlineOffset;
|
||||||
|
nscoord mSpaceWidth;
|
||||||
|
|
||||||
#ifdef FONT_SWITCHING
|
#ifdef FONT_SWITCHING
|
||||||
|
|
||||||
|
|
|
@ -958,6 +958,12 @@ NS_IMETHODIMP
|
||||||
nsRenderingContextXlib::GetWidth(char aC, nscoord& aWidth)
|
nsRenderingContextXlib::GetWidth(char aC, nscoord& aWidth)
|
||||||
{
|
{
|
||||||
printf("nsRenderingContextXlib::GetWidth()\n");
|
printf("nsRenderingContextXlib::GetWidth()\n");
|
||||||
|
// Check for the very common case of trying to get the width of a single
|
||||||
|
// space.
|
||||||
|
if ((aC == ' ') && (nsnull != mFontMetrics)) {
|
||||||
|
nsFontMetricsXlib* fontMetricsXlib = (nsFontMetricsXlib*)mFontMetrics;
|
||||||
|
return fontMetricsXlib->GetSpaceWidth(aWidth);
|
||||||
|
}
|
||||||
return GetWidth(&aC, 1, aWidth);
|
return GetWidth(&aC, 1, aWidth);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Загрузка…
Ссылка в новой задаче