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

Commit 806a6f07 authored by Tom Hudson's avatar Tom Hudson Committed by Derek Sollenberger
Browse files

Fix onDrawText for non-absolute positioning

If we were drawing text with drawTextAbsolutePos() false, we would
draw the first character at 0,0 but subsequent characters would get
improperly offset by y. (or x if vertical text)

Change-Id: I4e76cd9d95bf1bb6ac021d99ef7cdd6333a290ba
parent f580c916
Loading
Loading
Loading
Loading
+7 −5
Original line number Diff line number Diff line
@@ -228,21 +228,23 @@ void SkiaCanvasProxy::onDrawText(const void* text, size_t byteLength, SkScalar x
    }

    // setup the first glyph position and adjust bounds if needed
    int xBaseline = 0;
    int yBaseline = 0;
    if (mCanvas->drawTextAbsolutePos()) {
        bounds.offset(x,y);
        pointStorage[0].set(x, y);
    } else {
        pointStorage[0].set(0, 0);
        xBaseline = x;
        yBaseline = y;
    }
    pointStorage[0].set(xBaseline, yBaseline);

    // setup the remaining glyph positions
    if (glyphs.paint.isVerticalText()) {
        for (int i = 1; i < glyphs.count; i++) {
            pointStorage[i].set(x, glyphWidths[i-1] + pointStorage[i-1].fY);
            pointStorage[i].set(xBaseline, glyphWidths[i-1] + pointStorage[i-1].fY);
        }
    } else {
        for (int i = 1; i < glyphs.count; i++) {
            pointStorage[i].set(glyphWidths[i-1] + pointStorage[i-1].fX, y);
            pointStorage[i].set(glyphWidths[i-1] + pointStorage[i-1].fX, yBaseline);
        }
    }