diff options
author | Herb Derby <herb@google.com> | 2017-01-03 14:15:11 -0500 |
---|---|---|
committer | Skia Commit-Bot <skia-commit-bot@chromium.org> | 2017-01-03 19:51:03 +0000 |
commit | 428dfe01fca286d6ef952242388a1075b80bb4ee (patch) | |
tree | 151e6e296e47c403d9af4607636b7c230d6c5e2d /src/core/SkFindAndPlaceGlyph.h | |
parent | e3374d68932ce5bd1e6a50b05a6764a543c00c39 (diff) |
Fix: when pos is not finite, text pointer not advanced.
This fixes a problem introduced by change https://skia-review.googlesource.com/6404.
BUG=skia:6076
Change-Id: Iabf05c40284700dc32431f92df5ba5fcdb6cac1d
Reviewed-on: https://skia-review.googlesource.com/6534
Reviewed-by: Ben Wagner <bungeman@google.com>
Commit-Queue: Herb Derby <herb@google.com>
Diffstat (limited to 'src/core/SkFindAndPlaceGlyph.h')
-rw-r--r-- | src/core/SkFindAndPlaceGlyph.h | 21 |
1 files changed, 10 insertions, 11 deletions
diff --git a/src/core/SkFindAndPlaceGlyph.h b/src/core/SkFindAndPlaceGlyph.h index 4e0c9f1dcf..c17dccbe3e 100644 --- a/src/core/SkFindAndPlaceGlyph.h +++ b/src/core/SkFindAndPlaceGlyph.h @@ -436,10 +436,7 @@ private: SkPoint findAndPositionGlyph( const char** text, SkPoint position, ProcessOneGlyph&& processOneGlyph) override { - if (!SkScalarsAreFinite(position.fX, position.fY)) { - return position; - } - SkPoint finalPosition = position; + if (kTextAlignment != SkPaint::kLeft_Align) { // Get the width of an un-sub-pixel positioned glyph for calculating the // alignment. This is not needed for kLeftAlign because its adjustment is @@ -450,26 +447,28 @@ private: if (metricGlyph.fWidth <= 0) { // Exiting early, be sure to update text pointer. *text = tempText; - return finalPosition + SkPoint{SkFloatToScalar(metricGlyph.fAdvanceX), - SkFloatToScalar(metricGlyph.fAdvanceY)}; + return position + SkPoint{SkFloatToScalar(metricGlyph.fAdvanceX), + SkFloatToScalar(metricGlyph.fAdvanceY)}; } // Adjust the final position by the alignment adjustment. - finalPosition -= TextAlignmentAdjustment(kTextAlignment, metricGlyph); + position -= TextAlignmentAdjustment(kTextAlignment, metricGlyph); } // Find the glyph. - SkIPoint lookupPosition = SubpixelAlignment(kAxisAlignment, finalPosition); + SkIPoint lookupPosition = SkScalarsAreFinite(position.fX, position.fY) + ? SubpixelAlignment(kAxisAlignment, position) + : SkIPoint{0, 0}; const SkGlyph& renderGlyph = fGlyphFinder->lookupGlyphXY(text, lookupPosition.fX, lookupPosition.fY); // If the glyph has no width (no pixels) then don't bother processing it. if (renderGlyph.fWidth > 0) { - processOneGlyph(renderGlyph, finalPosition, + processOneGlyph(renderGlyph, position, SubpixelPositionRounding(kAxisAlignment)); } - return finalPosition + SkPoint{SkFloatToScalar(renderGlyph.fAdvanceX), - SkFloatToScalar(renderGlyph.fAdvanceY)}; + return position + SkPoint{SkFloatToScalar(renderGlyph.fAdvanceX), + SkFloatToScalar(renderGlyph.fAdvanceY)}; } private: |