Improve correctness of SkiaCanvas::drawLayoutOnPath

Align glyph to a tangent touching SkPath in the midle of the
symbol. Previously wrong tangent crossing the path at the
beginning of the glyph was used.

Test: Ran the test app attached to the bug
Bug: 71525360
Change-Id: I310394d11e185de314f66a6b332f804188e42ed9
diff --git a/libs/hwui/SkiaCanvas.cpp b/libs/hwui/SkiaCanvas.cpp
index 13e1ebe..2e08670 100644
--- a/libs/hwui/SkiaCanvas.cpp
+++ b/libs/hwui/SkiaCanvas.cpp
@@ -765,7 +765,8 @@
 
     for (size_t i = start; i < end; i++) {
         glyphs[i - start] = layout.getGlyphId(i);
-        float x = hOffset + layout.getX(i);
+        float halfWidth = layout.getCharAdvance(i) * 0.5f;
+        float x = hOffset + layout.getX(i) + halfWidth;
         float y = vOffset + layout.getY(i);
 
         SkPoint pos;
@@ -776,8 +777,8 @@
         }
         xform[i - start].fSCos = tan.x();
         xform[i - start].fSSin = tan.y();
-        xform[i - start].fTx = pos.x() - tan.y() * y;
-        xform[i - start].fTy = pos.y() + tan.x() * y;
+        xform[i - start].fTx = pos.x() - tan.y() * y - halfWidth * tan.x();
+        xform[i - start].fTy = pos.y() + tan.x() * y - halfWidth * tan.y();
     }
 
     this->asSkCanvas()->drawTextRSXform(glyphs, sizeof(uint16_t) * N, xform, nullptr, paint);