Skip to content

Commit 155fa38

Browse files
author
Fabrice Di Meglio
committed
Fix potential issue with the TextLayoutCache with glyphs
- there may be a mapping of one char to many glyphs Change-Id: I48846d176d61dc8d8e513ca144fdf8ad805e63b7
1 parent d4ad7b4 commit 155fa38

File tree

1 file changed

+3
-1
lines changed

1 file changed

+3
-1
lines changed

core/jni/android/graphics/TextLayoutCache.cpp

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -620,7 +620,9 @@ void TextLayoutCacheValue::getGlyphsIndexAndCount(size_t start, size_t count, si
620620
return;
621621
}
622622
*outStartIndex = mLogClusters[start];
623-
*outGlyphsCount = mLogClusters[start + count - 1] - mLogClusters[start] + 1;
623+
size_t endIndex = (start + count >= mAdvances.size()) ?
624+
mGlyphs.size() : mLogClusters[start + count];
625+
*outGlyphsCount = endIndex - *outStartIndex;
624626
#if DEBUG_GLYPHS
625627
LOGD("getGlyphsIndexes - start=%d count=%d - startIndex=%d count=%d", start, count,
626628
*outStartIndex, *outGlyphsCount);

0 commit comments

Comments
 (0)