Bug 406299. Make sure we include the font ascent/descent of a soft hyphen if there is one (gfx bits). r+sr=dbaron

This commit is contained in:
Robert O'Callahan 2008-08-12 21:34:52 +12:00
Родитель 1d75b20afc
Коммит cd221bb533
2 изменённых файлов: 19 добавлений и 22 удалений

Просмотреть файл

@ -521,19 +521,13 @@ public:
/** /**
* Metrics for a particular string * Metrics for a particular string
*/ */
struct RunMetrics { struct THEBES_API RunMetrics {
RunMetrics() { RunMetrics() {
mAdvanceWidth = mAscent = mDescent = 0.0; mAdvanceWidth = mAscent = mDescent = 0.0;
mBoundingBox = gfxRect(0,0,0,0); mBoundingBox = gfxRect(0,0,0,0);
} }
void CombineWith(const RunMetrics& aOtherOnRight) { void CombineWith(const RunMetrics& aOther, PRBool aOtherIsOnLeft);
mAscent = PR_MAX(mAscent, aOtherOnRight.mAscent);
mDescent = PR_MAX(mDescent, aOtherOnRight.mDescent);
mBoundingBox =
mBoundingBox.Union(aOtherOnRight.mBoundingBox + gfxPoint(mAdvanceWidth, 0));
mAdvanceWidth += aOtherOnRight.mAdvanceWidth;
}
// can be negative (partly due to negative spacing). // can be negative (partly due to negative spacing).
// Advance widths should be additive: the advance width of the // Advance widths should be additive: the advance width of the

Просмотреть файл

@ -246,6 +246,21 @@ gfxFontCache::DestroyFont(gfxFont *aFont)
delete aFont; delete aFont;
} }
void
gfxFont::RunMetrics::CombineWith(const RunMetrics& aOther, PRBool aOtherIsOnLeft)
{
mAscent = PR_MAX(mAscent, aOther.mAscent);
mDescent = PR_MAX(mDescent, aOther.mDescent);
if (aOtherIsOnLeft) {
mBoundingBox =
(mBoundingBox + gfxPoint(aOther.mAdvanceWidth, 0)).Union(aOther.mBoundingBox);
} else {
mBoundingBox =
mBoundingBox.Union(aOther.mBoundingBox + gfxPoint(mAdvanceWidth, 0));
}
mAdvanceWidth += aOther.mAdvanceWidth;
}
gfxFont::gfxFont(gfxFontEntry *aFontEntry, const gfxFontStyle *aFontStyle) : gfxFont::gfxFont(gfxFontEntry *aFontEntry, const gfxFontStyle *aFontStyle) :
mIsValid(PR_TRUE), mStyle(*aFontStyle), mFontEntry(aFontEntry), mSyntheticBoldOffset(0) mIsValid(PR_TRUE), mStyle(*aFontStyle), mFontEntry(aFontEntry), mSyntheticBoldOffset(0)
{ {
@ -1753,7 +1768,6 @@ gfxTextRun::DrawToPath(gfxContext *aContext, gfxPoint aPt,
} }
} }
void void
gfxTextRun::AccumulateMetricsForRun(gfxFont *aFont, gfxTextRun::AccumulateMetricsForRun(gfxFont *aFont,
PRUint32 aStart, PRUint32 aEnd, PRUint32 aStart, PRUint32 aEnd,
@ -1767,13 +1781,7 @@ gfxTextRun::AccumulateMetricsForRun(gfxFont *aFont,
aSpacingStart, aSpacingEnd, &spacingBuffer); aSpacingStart, aSpacingEnd, &spacingBuffer);
Metrics metrics = aFont->Measure(this, aStart, aEnd, aTight, aRefContext, Metrics metrics = aFont->Measure(this, aStart, aEnd, aTight, aRefContext,
haveSpacing ? spacingBuffer.Elements() : nsnull); haveSpacing ? spacingBuffer.Elements() : nsnull);
aMetrics->CombineWith(metrics, IsRightToLeft());
if (IsRightToLeft()) {
metrics.CombineWith(*aMetrics);
*aMetrics = metrics;
} else {
aMetrics->CombineWith(metrics);
}
} }
void void
@ -1809,12 +1817,7 @@ gfxTextRun::AccumulatePartialLigatureMetrics(gfxFont *aFont,
: data.mPartAdvance; : data.mPartAdvance;
metrics.mAdvanceWidth = data.mPartWidth; metrics.mAdvanceWidth = data.mPartWidth;
if (IsRightToLeft()) { aMetrics->CombineWith(metrics, IsRightToLeft());
metrics.CombineWith(*aMetrics);
*aMetrics = metrics;
} else {
aMetrics->CombineWith(metrics);
}
} }
gfxTextRun::Metrics gfxTextRun::Metrics