Bug 429899. Always treat the first character of a ligature as the start of a cluster when dividing ligature width among clusters. r+a=vlad

This commit is contained in:
roc+%cs.cmu.edu 2008-04-23 02:06:22 +00:00
Родитель 5f5ff03eec
Коммит d023abdf77
2 изменённых файлов: 22 добавлений и 9 удалений

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

@ -1271,8 +1271,8 @@ public:
// when the part is as the end of the ligature
gfxFloat mPartWidth;
PRPackedBool mPartIsStartOfLigature;
PRPackedBool mPartIsEndOfLigature;
PRPackedBool mClipBeforePart;
PRPackedBool mClipAfterPart;
};
#ifdef DEBUG

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

@ -1191,7 +1191,10 @@ gfxTextRun::ComputeLigatureData(PRUint32 aPartStart, PRUint32 aPartEnd,
PRUint32 partClusterIndex = 0;
PRUint32 partClusterCount = 0;
for (i = result.mLigatureStart; i < result.mLigatureEnd; ++i) {
if (charGlyphs[i].IsClusterStart()) {
// Treat the first character of the ligature as the start of a
// cluster for our purposes of allocating ligature width to its
// characters.
if (i == result.mLigatureStart || charGlyphs[i].IsClusterStart()) {
++totalClusterCount;
if (i < aPartStart) {
++partClusterIndex;
@ -1202,8 +1205,20 @@ gfxTextRun::ComputeLigatureData(PRUint32 aPartStart, PRUint32 aPartEnd,
}
result.mPartAdvance = ligatureWidth*partClusterIndex/totalClusterCount;
result.mPartWidth = ligatureWidth*partClusterCount/totalClusterCount;
result.mPartIsStartOfLigature = partClusterIndex == 0;
result.mPartIsEndOfLigature = partClusterIndex + partClusterCount == totalClusterCount;
if (partClusterCount == 0) {
// nothing to draw
result.mClipBeforePart = result.mClipAfterPart = PR_TRUE;
} else {
// Determine whether we should clip before or after this part when
// drawing its slice of the ligature.
// We need to clip before the part if any cluster is drawn before
// this part.
result.mClipBeforePart = partClusterIndex > 0;
// We need to clip after the part if any cluster is drawn after
// this part.
result.mClipAfterPart = partClusterIndex + partClusterCount < totalClusterCount;
}
if (aProvider && (mFlags & gfxTextRunFactory::TEXT_ENABLE_SPACING)) {
gfxFont::Spacing spacing;
@ -1310,16 +1325,14 @@ static void
ClipPartialLigature(gfxTextRun *aTextRun, gfxFloat *aLeft, gfxFloat *aRight,
gfxFloat aXOrigin, gfxTextRun::LigatureData *aLigature)
{
if (!aLigature->mPartIsStartOfLigature) {
// need to clip the ligature before the part
if (aLigature->mClipBeforePart) {
if (aTextRun->IsRightToLeft()) {
*aRight = PR_MIN(*aRight, aXOrigin);
} else {
*aLeft = PR_MAX(*aLeft, aXOrigin);
}
}
if (!aLigature->mPartIsEndOfLigature) {
// need to clip the ligature after the part
if (aLigature->mClipAfterPart) {
gfxFloat endEdge = aXOrigin + aTextRun->GetDirection()*aLigature->mPartWidth;
if (aTextRun->IsRightToLeft()) {
*aLeft = PR_MAX(*aLeft, endEdge);