@@ -550,6 +550,10 @@ void TextLayoutShaper::computeRunValues(const SkPaint* paint, const UChar* chars
550550 return ;
551551 }
552552
553+ // To be filled in later
554+ for (size_t i = 0 ; i < count; i++) {
555+ outAdvances->add (0 );
556+ }
553557 UErrorCode error = U_ZERO_ERROR;
554558 bool useNormalizedString = false ;
555559 for (ssize_t i = count - 1 ; i >= 0 ; --i) {
@@ -691,23 +695,11 @@ void TextLayoutShaper::computeRunValues(const SkPaint* paint, const UChar* chars
691695
692696 logGlyphs (mShaperItem );
693697#endif
694- if (isRTL) {
695- endScriptRun = startScriptRun;
696- #if DEBUG_GLYPHS
697- ALOGD (" Updated endScriptRun = %d" , int (endScriptRun));
698- #endif
699- } else {
700- startScriptRun = endScriptRun;
701- #if DEBUG_GLYPHS
702- ALOGD (" Updated startScriptRun = %d" , int (startScriptRun));
703- #endif
704- }
705698
706699 if (mShaperItem .advances == NULL || mShaperItem .num_glyphs == 0 ) {
707700#if DEBUG_GLYPHS
708701 ALOGD (" Advances array is empty or num_glypth = 0" );
709702#endif
710- outAdvances->insertAt (0 , outAdvances->size (), countScriptRun);
711703 continue ;
712704 }
713705
@@ -721,15 +713,13 @@ void TextLayoutShaper::computeRunValues(const SkPaint* paint, const UChar* chars
721713 // Get Advances and their total
722714 jfloat currentAdvance = HBFixedToFloat (mShaperItem .advances [mShaperItem .log_clusters [0 ]]);
723715 jfloat totalFontRunAdvance = currentAdvance;
724- outAdvances->add (currentAdvance);
716+ outAdvances->replaceAt (currentAdvance, startScriptRun );
725717 for (size_t i = 1 ; i < countScriptRun; i++) {
726718 size_t clusterPrevious = mShaperItem .log_clusters [i - 1 ];
727719 size_t cluster = mShaperItem .log_clusters [i];
728- if (cluster == clusterPrevious) {
729- outAdvances->add (0 );
730- } else {
720+ if (cluster != clusterPrevious) {
731721 currentAdvance = HBFixedToFloat (mShaperItem .advances [mShaperItem .log_clusters [i]]);
732- outAdvances->add (currentAdvance);
722+ outAdvances->replaceAt (currentAdvance, startScriptRun + i );
733723 }
734724 }
735725 // TODO: can be removed and go back in the previous loop when Harfbuzz log clusters are fixed
@@ -746,6 +736,7 @@ void TextLayoutShaper::computeRunValues(const SkPaint* paint, const UChar* chars
746736 (*outAdvances)[i], mShaperItem .log_clusters [i], totalFontRunAdvance);
747737 }
748738#endif
739+
749740 // Get Glyphs and reverse them in place if RTL
750741 if (outGlyphs) {
751742 size_t countGlyphs = mShaperItem .num_glyphs ;
0 commit comments