OLD | NEW |
1 /* | 1 /* |
2 * Copyright 2015 Google Inc. | 2 * Copyright 2015 Google Inc. |
3 * | 3 * |
4 * Use of this source code is governed by a BSD-style license that can be | 4 * Use of this source code is governed by a BSD-style license that can be |
5 * found in the LICENSE file. | 5 * found in the LICENSE file. |
6 */ | 6 */ |
7 | 7 |
8 #ifndef SkFindAndPositionGlyph_DEFINED | 8 #ifndef SkFindAndPositionGlyph_DEFINED |
9 #define SkFindAndPositionGlyph_DEFINED | 9 #define SkFindAndPositionGlyph_DEFINED |
10 | 10 |
(...skipping 290 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
301 void findAndPositionGlyph(const char** text, SkPoint position, | 301 void findAndPositionGlyph(const char** text, SkPoint position, |
302 ProcessOneGlyph&& processOneGlyph) override { | 302 ProcessOneGlyph&& processOneGlyph) override { |
303 SkPoint finalPosition = position; | 303 SkPoint finalPosition = position; |
304 if (kTextAlignment != SkPaint::kLeft_Align) { | 304 if (kTextAlignment != SkPaint::kLeft_Align) { |
305 // Get the width of an un-sub-pixel positioned glyph for calcula
ting the alignment. | 305 // Get the width of an un-sub-pixel positioned glyph for calcula
ting the alignment. |
306 // This is not needed for kLeftAlign because its adjustment is a
lways {0, 0}. | 306 // This is not needed for kLeftAlign because its adjustment is a
lways {0, 0}. |
307 const char* tempText = *text; | 307 const char* tempText = *text; |
308 const SkGlyph &metricGlyph = fGlyphCacheProc(fCache, &tempText,
0, 0); | 308 const SkGlyph &metricGlyph = fGlyphCacheProc(fCache, &tempText,
0, 0); |
309 | 309 |
310 if (metricGlyph.fWidth <= 0) { | 310 if (metricGlyph.fWidth <= 0) { |
| 311 // Exiting early, be sure to update text pointer. |
| 312 *text = tempText; |
311 return; | 313 return; |
312 } | 314 } |
313 | 315 |
314 // Adjust the final position by the alignment adjustment. | 316 // Adjust the final position by the alignment adjustment. |
315 finalPosition -= TextAlignmentAdjustment(kTextAlignment, metricG
lyph); | 317 finalPosition -= TextAlignmentAdjustment(kTextAlignment, metricG
lyph); |
316 } | 318 } |
317 | 319 |
318 // Find the glyph. | 320 // Find the glyph. |
319 SkIPoint lookupPosition = SubpixelAlignment(kAxisAlignment, finalPos
ition); | 321 SkIPoint lookupPosition = SubpixelAlignment(kAxisAlignment, finalPos
ition); |
320 const SkGlyph& renderGlyph = fGlyphCacheProc( | 322 const SkGlyph& renderGlyph = fGlyphCacheProc( |
(...skipping 193 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
514 positioner.Positioner::findAndPositionGlyph( | 516 positioner.Positioner::findAndPositionGlyph( |
515 &cursor, mappedPoint, skstd::forward<ProcessOneGlyph>(processOne
Glyph)); | 517 &cursor, mappedPoint, skstd::forward<ProcessOneGlyph>(processOne
Glyph)); |
516 } | 518 } |
517 return true; | 519 return true; |
518 } | 520 } |
519 return false; | 521 return false; |
520 } | 522 } |
521 | 523 |
522 | 524 |
523 #endif // SkFindAndPositionGlyph_DEFINED | 525 #endif // SkFindAndPositionGlyph_DEFINED |
OLD | NEW |