Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit c7c09960 authored by Fabrice Di Meglio's avatar Fabrice Di Meglio Committed by Android (Google) Code Review
Browse files

Merge "Fix bug #5870701 Thai text can be clipped when there are more glyphs...

Merge "Fix bug #5870701 Thai text can be clipped when there are more glyphs generated than the initial number of code points"
parents fb6b5bdc 03e250ae
Loading
Loading
Loading
Loading
+12 −3
Original line number Diff line number Diff line
@@ -659,6 +659,13 @@ void TextLayoutEngine::computeRunValues(SkPaint* paint, const UChar* chars,
            continue;
        }

#if DEBUG_GLYPHS
        ALOGD("Returned logclusters");
        for (size_t i = 0; i < mShaperItem.num_glyphs; i++) {
            ALOGD("         -- lc[%d] = %d, hb-adv[%d] = %0.2f", i, mShaperItem.log_clusters[i],
                    i, HBFixedToFloat(mShaperItem.advances[i]));
        }
#endif
        // Get Advances and their total
        jfloat currentAdvance = HBFixedToFloat(mShaperItem.advances[mShaperItem.log_clusters[0]]);
        jfloat totalFontRunAdvance = currentAdvance;
@@ -670,11 +677,14 @@ void TextLayoutEngine::computeRunValues(SkPaint* paint, const UChar* chars,
                outAdvances->add(0);
            } else {
                currentAdvance = HBFixedToFloat(mShaperItem.advances[mShaperItem.log_clusters[i]]);
                totalFontRunAdvance += currentAdvance;
                outAdvances->add(currentAdvance);
            }
        }

        // TODO: can be removed and go back in the previous loop when Harfbuzz log clusters are fixed
        for (size_t i = 1; i < mShaperItem.num_glyphs; i++) {
            currentAdvance = HBFixedToFloat(mShaperItem.advances[i]);
            totalFontRunAdvance += currentAdvance;
        }
        totalAdvance += totalFontRunAdvance;

#if DEBUG_ADVANCES
@@ -684,7 +694,6 @@ void TextLayoutEngine::computeRunValues(SkPaint* paint, const UChar* chars,
                    (*outAdvances)[i], mShaperItem.log_clusters[i], totalFontRunAdvance);
        }
#endif

        // Get Glyphs and reverse them in place if RTL
        if (outGlyphs) {
            size_t countGlyphs = mShaperItem.num_glyphs;
+1 −0
Original line number Diff line number Diff line
@@ -50,5 +50,6 @@
    <string name="rtl">"والحق أن تترك ونص"</string>
    <string name="composing">"\u0644\u0627"</string>
    <string name="url">www.amazon.co.uk/gp/aw/h.html/275-8912818-8203452</string>
    <string name="pointer_location" msgid="6084434787496938001">"ตำแหน่งของตัวชี้"</string>
</resources>
+6 −0
Original line number Diff line number Diff line
@@ -51,6 +51,7 @@ public class BiDiTestView extends View {
    private String MIXED_TEXT_1;
    private String HEBREW_TEXT;
    private String RTL_TEXT;
    private String THAI_TEXT;

    private int currentTextSize;

@@ -82,6 +83,7 @@ public class BiDiTestView extends View {
        MIXED_TEXT_1 = context.getString(R.string.mixed_text_1);
        HEBREW_TEXT = context.getString(R.string.hebrew_text);
        RTL_TEXT = context.getString(R.string.rtl);
        THAI_TEXT = context.getString(R.string.pointer_location);
    }

    public void setCurrentTextSize(int size) {
@@ -134,6 +136,10 @@ public class BiDiTestView extends View {
        // Test Hebrew
        deltaX = testString(canvas, RTL_TEXT, ORIGIN, ORIGIN + 14 * currentTextSize,
                false, false,  Paint.DIRECTION_RTL, currentTextSize);

        // Test Thai
        deltaX = testString(canvas, THAI_TEXT, ORIGIN, ORIGIN + 16 * currentTextSize,
                false, false,  Paint.DIRECTION_LTR, currentTextSize);
    }

    private int testString(Canvas canvas, String text, int x, int y,