From 3393c5cdba65a7cc4cd523ab66f94d5020004b5d Mon Sep 17 00:00:00 2001 From: felixkrautschuk Date: Tue, 23 Sep 2025 15:40:42 +0200 Subject: [PATCH] fix(android): prevent clipped font icons on Android Add a 1px padding on each edge when creating the bitmap, this guarantees enough space for fractional/anti-aliased edges across all DPIs and devices. --- packages/core/image-source/index.android.ts | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/packages/core/image-source/index.android.ts b/packages/core/image-source/index.android.ts index 2248028774..cd4d7938f6 100644 --- a/packages/core/image-source/index.android.ts +++ b/packages/core/image-source/index.android.ts @@ -181,13 +181,14 @@ export class ImageSource implements ImageSourceDefinition { const textBounds = new android.graphics.Rect(); paint.getTextBounds(source, 0, source.length, textBounds); - const textWidth = textBounds.width(); - const textHeight = textBounds.height(); + const padding = 1; + const textWidth = textBounds.width() + padding * 2; + const textHeight = textBounds.height() + padding * 2; if (textWidth > 0 && textHeight > 0) { const bitmap = android.graphics.Bitmap.createBitmap(textWidth, textHeight, android.graphics.Bitmap.Config.ARGB_8888); const canvas = new android.graphics.Canvas(bitmap); - canvas.drawText(source, -textBounds.left, -textBounds.top, paint); + canvas.drawText(source, -textBounds.left + padding, -textBounds.top + padding, paint); return new ImageSource(bitmap); }