fix(android): prevent clipped font icons on Android (#10858)

This commit is contained in:
felixkrautschuk
2025-10-30 01:01:33 +01:00
committed by GitHub
parent e1ff2982e8
commit 8d3c3c3416

View File

@ -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);
}