Skip to content

Conversation

@felixkrautschuk
Copy link
Contributor

@felixkrautschuk felixkrautschuk commented Sep 23, 2025

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.

PR Checklist

What is the current behavior?

Right now, font icons used in Image or ActionItem etc (font://...) mitght get clipped on the top and right on certain devices/dpis, 1px is missing on top and right.

Bildschirmfoto 2025-09-23 um 16 38 46

This is because NativeScript currently uses:

paint.getTextBounds(source, 0, source.length, textBounds);
const bitmap = Bitmap.createBitmap(textBounds.width(), textBounds.height(), ...);
canvas.drawText(source, -textBounds.left, -textBounds.top, paint);

getTextBounds returns an integer rectangle, rounded down.
The actual glyph rasterization may extend slightly beyond this box due to fractional scaling and anti-aliasing.

What is the new behavior?

1px padding is added on each edge when creating the bitmap:

const padding = 1;
const bitmap = Bitmap.createBitmap(
    textBounds.width() + padding * 2,
    textBounds.height() + padding * 2,
    Bitmap.Config.ARGB_8888
);
canvas.drawText(
    source,
    -textBounds.left + padding,
    -textBounds.top + padding,
    paint
);

This guarantees enough space for fractional/anti-aliased edges across all DPIs and devices.

Bildschirmfoto 2025-09-23 um 16 41 02

Fixes/Implements/Closes #10857 .

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.
@nx-cloud
Copy link

nx-cloud bot commented Sep 23, 2025

View your CI Pipeline Execution ↗ for commit 3393c5c

Command Status Duration Result
nx test apps-automated -c=android ✅ Succeeded 2s View ↗
nx run-many --target=test --configuration=ci --... ✅ Succeeded 3s View ↗

☁️ Nx Cloud last updated this comment at 2025-09-23 15:03:31 UTC

@NathanWalker NathanWalker added this to the 9.0 milestone Oct 29, 2025
@NathanWalker NathanWalker merged commit 8d3c3c3 into NativeScript:main Oct 30, 2025
4 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Android: font icon (font://...) in ActionItem or Image gets clipped

2 participants