diff options
| author | 2012-07-30 15:50:00 -0700 | |
|---|---|---|
| committer | 2012-07-30 15:53:16 -0700 | |
| commit | 8b4072d3fb9bb49d774d97689a065204beca1752 (patch) | |
| tree | 1356548f2453c28d23458375943c2b21bd91ceb4 /libs/hwui/OpenGLRenderer.cpp | |
| parent | e72a6e977b8436a993c427cf489f2ae05fdeface (diff) | |
Fix bug 6892600 Font (character pairs) rendering issue
Alignment on paint for actual glyph drawing needs to always be left,
even when drawing centered or right aligned text. The x offset for
alignment is applied by OpenGLRenderer::drawText (and needs to be early
in the pipeline for quickReject to work). Similar change needed for
drawing drop shadow.
Also fixes bug with mispositioned underline (offset for alignment has
already been applied once, no need to do it again in
drawTextDecorations).
Change-Id: Id3dcd62de5536a26b158d768889273a1492b35d6
Diffstat (limited to 'libs/hwui/OpenGLRenderer.cpp')
| -rw-r--r-- | libs/hwui/OpenGLRenderer.cpp | 25 |
1 files changed, 7 insertions, 18 deletions
diff --git a/libs/hwui/OpenGLRenderer.cpp b/libs/hwui/OpenGLRenderer.cpp index d0d5af5e5b2d..a1da87868701 100644 --- a/libs/hwui/OpenGLRenderer.cpp +++ b/libs/hwui/OpenGLRenderer.cpp @@ -2508,13 +2508,14 @@ status_t OpenGLRenderer::drawText(const char* text, int bytesCount, int count, #endif bool status; - if (positions != NULL) { - status = fontRenderer.renderPosText(paint, clip, text, 0, bytesCount, count, x, y, + if (paint->getTextAlign() != SkPaint::kLeft_Align) { + SkPaint paintCopy(*paint); + paintCopy.setTextAlign(SkPaint::kLeft_Align); + status = fontRenderer.renderPosText(&paintCopy, clip, text, 0, bytesCount, count, x, y, positions, hasActiveLayer ? &bounds : NULL); } else { - // TODO: would it be okay to call renderPosText with null positions? - status = fontRenderer.renderText(paint, clip, text, 0, bytesCount, count, x, y, - hasActiveLayer ? &bounds : NULL); + status = fontRenderer.renderPosText(paint, clip, text, 0, bytesCount, count, x, y, + positions, hasActiveLayer ? &bounds : NULL); } if (status) { #if RENDER_LAYERS_AS_REGIONS @@ -2801,23 +2802,11 @@ void OpenGLRenderer::drawTextDecorations(const char* text, int bytesCount, float underlineWidth = paintCopy.measureText(text, bytesCount); } - float offsetX = 0; - switch (paintCopy.getTextAlign()) { - case SkPaint::kCenter_Align: - offsetX = underlineWidth * 0.5f; - break; - case SkPaint::kRight_Align: - offsetX = underlineWidth; - break; - default: - break; - } - if (CC_LIKELY(underlineWidth > 0.0f)) { const float textSize = paintCopy.getTextSize(); const float strokeWidth = fmax(textSize * kStdUnderline_Thickness, 1.0f); - const float left = x - offsetX; + const float left = x; float top = 0.0f; int linesCount = 0; |