mirror of
https://github.com/mozilla/gecko-dev.git
synced 2024-10-11 12:25:53 +00:00
bug 731187 - nsFontMetrics needs to handle possible failure of AutoTextRun to create the run. r=choller,roc
This commit is contained in:
parent
adfa2f07b4
commit
7b63ba0da8
@ -300,7 +300,8 @@ nsFontMetrics::GetWidth(const char* aString, PRUint32 aLength,
|
||||
|
||||
StubPropertyProvider provider;
|
||||
AutoTextRun textRun(this, aContext, aString, aLength);
|
||||
return NSToCoordRound(textRun->GetAdvanceWidth(0, aLength, &provider));
|
||||
return textRun.get() ?
|
||||
NSToCoordRound(textRun->GetAdvanceWidth(0, aLength, &provider)) : 0;
|
||||
}
|
||||
|
||||
nscoord
|
||||
@ -315,7 +316,8 @@ nsFontMetrics::GetWidth(const PRUnichar* aString, PRUint32 aLength,
|
||||
|
||||
StubPropertyProvider provider;
|
||||
AutoTextRun textRun(this, aContext, aString, aLength);
|
||||
return NSToCoordRound(textRun->GetAdvanceWidth(0, aLength, &provider));
|
||||
return textRun.get() ?
|
||||
NSToCoordRound(textRun->GetAdvanceWidth(0, aLength, &provider)) : 0;
|
||||
}
|
||||
|
||||
// Draw a string using this font handle on the surface passed in.
|
||||
@ -329,6 +331,9 @@ nsFontMetrics::DrawString(const char *aString, PRUint32 aLength,
|
||||
|
||||
StubPropertyProvider provider;
|
||||
AutoTextRun textRun(this, aContext, aString, aLength);
|
||||
if (!textRun.get()) {
|
||||
return;
|
||||
}
|
||||
gfxPoint pt(aX, aY);
|
||||
if (mTextRunRTL) {
|
||||
pt.x += textRun->GetAdvanceWidth(0, aLength, &provider);
|
||||
@ -348,6 +353,9 @@ nsFontMetrics::DrawString(const PRUnichar* aString, PRUint32 aLength,
|
||||
|
||||
StubPropertyProvider provider;
|
||||
AutoTextRun textRun(this, aTextRunConstructionContext, aString, aLength);
|
||||
if (!textRun.get()) {
|
||||
return;
|
||||
}
|
||||
gfxPoint pt(aX, aY);
|
||||
if (mTextRunRTL) {
|
||||
pt.x += textRun->GetAdvanceWidth(0, aLength, &provider);
|
||||
@ -365,16 +373,18 @@ nsFontMetrics::GetBoundingMetrics(const PRUnichar *aString, PRUint32 aLength,
|
||||
|
||||
StubPropertyProvider provider;
|
||||
AutoTextRun textRun(this, aContext, aString, aLength);
|
||||
gfxTextRun::Metrics theMetrics =
|
||||
textRun->MeasureText(0, aLength,
|
||||
gfxFont::TIGHT_HINTED_OUTLINE_EXTENTS,
|
||||
aContext->ThebesContext(), &provider);
|
||||
|
||||
nsBoundingMetrics m;
|
||||
m.leftBearing = NSToCoordFloor( theMetrics.mBoundingBox.X());
|
||||
m.rightBearing = NSToCoordCeil( theMetrics.mBoundingBox.XMost());
|
||||
m.ascent = NSToCoordCeil( -theMetrics.mBoundingBox.Y());
|
||||
m.descent = NSToCoordCeil( theMetrics.mBoundingBox.YMost());
|
||||
m.width = NSToCoordRound( theMetrics.mAdvanceWidth);
|
||||
if (textRun.get()) {
|
||||
gfxTextRun::Metrics theMetrics =
|
||||
textRun->MeasureText(0, aLength,
|
||||
gfxFont::TIGHT_HINTED_OUTLINE_EXTENTS,
|
||||
aContext->ThebesContext(), &provider);
|
||||
|
||||
m.leftBearing = NSToCoordFloor( theMetrics.mBoundingBox.X());
|
||||
m.rightBearing = NSToCoordCeil( theMetrics.mBoundingBox.XMost());
|
||||
m.ascent = NSToCoordCeil( -theMetrics.mBoundingBox.Y());
|
||||
m.descent = NSToCoordCeil( theMetrics.mBoundingBox.YMost());
|
||||
m.width = NSToCoordRound( theMetrics.mAdvanceWidth);
|
||||
}
|
||||
return m;
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user