Skip to content

Commit 54801e1

Browse files
raphlinusAndroid (Google) Code Review
authored andcommitted
Merge "Fix for bug 6936752 Tamil text gets truncated on right-hand side" into jb-mr1-dev
2 parents 0199679 + 1b10241 commit 54801e1

File tree

1 file changed

+15
-14
lines changed

1 file changed

+15
-14
lines changed

core/jni/android/graphics/TextLayoutCache.cpp

Lines changed: 15 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -686,23 +686,24 @@ void TextLayoutShaper::computeRunValues(const SkPaint* paint, const UChar* chars
686686
i, HBFixedToFloat(mShaperItem.advances[i]));
687687
}
688688
#endif
689-
// Get Advances and their total
690-
jfloat currentAdvance = HBFixedToFloat(mShaperItem.advances[mShaperItem.log_clusters[0]]);
691-
jfloat totalFontRunAdvance = currentAdvance;
692-
outAdvances->replaceAt(currentAdvance, startScriptRun);
693-
for (size_t i = 1; i < countScriptRun; i++) {
694-
size_t clusterPrevious = mShaperItem.log_clusters[i - 1];
689+
jfloat totalFontRunAdvance = 0;
690+
size_t clusterStart = 0;
691+
for (size_t i = 0; i < countScriptRun; i++) {
695692
size_t cluster = mShaperItem.log_clusters[i];
696-
if (cluster != clusterPrevious) {
697-
currentAdvance = HBFixedToFloat(mShaperItem.advances[mShaperItem.log_clusters[i]]);
698-
outAdvances->replaceAt(currentAdvance, startScriptRun + i);
693+
size_t clusterNext = i == countScriptRun - 1 ? mShaperItem.num_glyphs :
694+
mShaperItem.log_clusters[i + 1];
695+
if (cluster != clusterNext) {
696+
jfloat advance = 0;
697+
// The advance for the cluster is the sum of the advances of all glyphs within
698+
// the cluster.
699+
for (size_t j = cluster; j < clusterNext; j++) {
700+
advance += HBFixedToFloat(mShaperItem.advances[j]);
701+
}
702+
totalFontRunAdvance += advance;
703+
outAdvances->replaceAt(advance, startScriptRun + clusterStart);
704+
clusterStart = i + 1;
699705
}
700706
}
701-
// TODO: can be removed and go back in the previous loop when Harfbuzz log clusters are fixed
702-
for (size_t i = 1; i < mShaperItem.num_glyphs; i++) {
703-
currentAdvance = HBFixedToFloat(mShaperItem.advances[i]);
704-
totalFontRunAdvance += currentAdvance;
705-
}
706707

707708
#if DEBUG_ADVANCES
708709
ALOGD("Returned advances");

0 commit comments

Comments
 (0)