Don't render text sequences as single character

This commit is contained in:
Sylvia van Os
2022-03-29 22:19:12 +02:00
parent d0d15393f6
commit 34639f2a2e

View File

@@ -73,9 +73,10 @@ class LetterBitmap {
String firstChar = displayName.substring(0, 1).toUpperCase();
int firstCharEnd = 2;
while (firstCharEnd <= displayName.length()) {
// test for the longest render-able string
// Test for the longest render-able string
// But ignore containing only a-Z0-9 to not render things like ffi as a single character
String test = displayName.substring(0, firstCharEnd);
if (PaintCompat.hasGlyph(paint, test)) {
if (!isAlphabetical(test) && PaintCompat.hasGlyph(paint, test)) {
firstChar = test;
}
firstCharEnd++;
@@ -124,6 +125,10 @@ class LetterBitmap {
return colors.getColor(color, Color.BLACK);
}
private static boolean isAlphabetical(String string) {
return string.matches("[a-zA-Z0-9]*");
}
/**
* Determine the color which the letter tile will use if no default
* color is provided.