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

Commit 9d9ee3d6 authored by Raph Levien's avatar Raph Levien
Browse files

BiDi support for Minikin

This patch plumbs the bidiFlags for the various text drawing and
measurement functions down to Minikin, so that the latter can do layout
in a BiDi-aware manner. With the corresponding changes to Minikin, it
is sufficient to correctly display RTL text in TextViews.

Change-Id: Ie904f297373b9ad418050a474506605c7c127b0f
parent 363e21b4
Loading
Loading
Loading
Loading
+1 −1
Original line number Diff line number Diff line
@@ -866,7 +866,7 @@ public:

#ifdef USE_MINIKIN
        Layout layout;
        MinikinUtils::SetLayoutProperties(&layout, paint, typeface);
        MinikinUtils::SetLayoutProperties(&layout, paint, flags, typeface);
        layout.doLayout(textArray + start, count);
        drawGlyphsToSkia(canvas, paint, &layout, x, y);
#else
+2 −0
Original line number Diff line number Diff line
@@ -57,7 +57,9 @@ float MinikinFontSkia::GetHorizontalAdvance(uint32_t glyph_id,
    SkScalar skWidth;
    MinikinFontSkia_SetSkiaPaint(mTypeface, &skPaint, paint);
    skPaint.getTextWidths(&glyph16, sizeof(glyph16), &skWidth, NULL);
#ifdef VERBOSE
    ALOGD("width for typeface %d glyph %d = %f", mTypeface->uniqueID(), glyph_id, skWidth);
#endif
    return skWidth;
}

+5 −4
Original line number Diff line number Diff line
@@ -22,16 +22,17 @@

namespace android {

void MinikinUtils::SetLayoutProperties(Layout* layout, SkPaint* paint,
void MinikinUtils::SetLayoutProperties(Layout* layout, SkPaint* paint, int flags,
    TypefaceImpl* typeface) {
    TypefaceImpl* resolvedFace = TypefaceImpl_resolveDefault(typeface);
    layout->setFontCollection(resolvedFace->fFontCollection);
    FontStyle style = resolvedFace->fStyle;
    char css[256];
    sprintf(css, "font-size: %d; font-weight: %d; font-style: %s",
    sprintf(css, "font-size: %d; font-weight: %d; font-style: %s; -minikin-bidi: %d",
        (int)paint->getTextSize(),
        style.getWeight() * 100,
        style.getItalic() ? "italic" : "normal");
        style.getItalic() ? "italic" : "normal",
        flags);
    layout->setProperties(css);
}

+1 −1
Original line number Diff line number Diff line
@@ -28,7 +28,7 @@ namespace android {

class MinikinUtils {
public:
    static void SetLayoutProperties(Layout* layout, SkPaint* paint,
    static void SetLayoutProperties(Layout* layout, SkPaint* paint, int flags,
        TypefaceImpl* face);
};

+5 −5
Original line number Diff line number Diff line
@@ -502,7 +502,7 @@ public:
#ifdef USE_MINIKIN
        Layout layout;
        TypefaceImpl* typeface = GraphicsJNI::getNativeTypeface(env, jpaint);
        MinikinUtils::SetLayoutProperties(&layout, paint, typeface);
        MinikinUtils::SetLayoutProperties(&layout, paint, bidiFlags, typeface);
        layout.doLayout(textArray + index, count);
        result = layout.getAdvance();
#else
@@ -536,7 +536,7 @@ public:
#ifdef USE_MINIKIN
        Layout layout;
        TypefaceImpl* typeface = GraphicsJNI::getNativeTypeface(env, jpaint);
        MinikinUtils::SetLayoutProperties(&layout, paint, typeface);
        MinikinUtils::SetLayoutProperties(&layout, paint, bidiFlags, typeface);
        layout.doLayout(textArray + start, count);
        width = layout.getAdvance();
#else
@@ -564,7 +564,7 @@ public:
#ifdef USE_MINIKIN
        Layout layout;
        TypefaceImpl* typeface = GraphicsJNI::getNativeTypeface(env, jpaint);
        MinikinUtils::SetLayoutProperties(&layout, paint, typeface);
        MinikinUtils::SetLayoutProperties(&layout, paint, bidiFlags, typeface);
        layout.doLayout(textArray, textLength);
        width = layout.getAdvance();
#else
@@ -599,7 +599,7 @@ public:

#ifdef USE_MINIKIN
        Layout layout;
        MinikinUtils::SetLayoutProperties(&layout, paint, typeface);
        MinikinUtils::SetLayoutProperties(&layout, paint, bidiFlags, typeface);
        layout.doLayout(text, count);
        layout.getAdvances(widthsArray);
#else
@@ -697,7 +697,7 @@ public:

#ifdef USE_MINIKIN
        Layout layout;
        MinikinUtils::SetLayoutProperties(&layout, paint, typeface);
        MinikinUtils::SetLayoutProperties(&layout, paint, flags, typeface);
        layout.doLayout(text + start, count);
        layout.getAdvances(advancesArray);
        totalAdvance = layout.getAdvance();
Loading