Skip to content

Commit 8d3c3c3

Browse files
fix(android): prevent clipped font icons on Android (#10858)
1 parent e1ff298 commit 8d3c3c3

File tree

1 file changed

+4
-3
lines changed

1 file changed

+4
-3
lines changed

packages/core/image-source/index.android.ts

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -181,13 +181,14 @@ export class ImageSource implements ImageSourceDefinition {
181181
const textBounds = new android.graphics.Rect();
182182
paint.getTextBounds(source, 0, source.length, textBounds);
183183

184-
const textWidth = textBounds.width();
185-
const textHeight = textBounds.height();
184+
const padding = 1;
185+
const textWidth = textBounds.width() + padding * 2;
186+
const textHeight = textBounds.height() + padding * 2;
186187
if (textWidth > 0 && textHeight > 0) {
187188
const bitmap = android.graphics.Bitmap.createBitmap(textWidth, textHeight, android.graphics.Bitmap.Config.ARGB_8888);
188189

189190
const canvas = new android.graphics.Canvas(bitmap);
190-
canvas.drawText(source, -textBounds.left, -textBounds.top, paint);
191+
canvas.drawText(source, -textBounds.left + padding, -textBounds.top + padding, paint);
191192

192193
return new ImageSource(bitmap);
193194
}

0 commit comments

Comments
 (0)