1
0
mirror of https://codeberg.org/Freeyourgadget/Gadgetbridge synced 2024-07-03 02:06:21 +02:00

Bangle.js: fix the rare case where we're converting an emoji/unicode to a bitmap but it doesn't have a width/height - we just create a bitmap of min. 1px

This commit is contained in:
Gordon Williams 2023-06-08 12:36:12 +01:00
parent e59375242e
commit b334773856

View File

@ -1336,6 +1336,8 @@ public class BangleJSDeviceSupport extends AbstractBTLEDeviceSupport {
float baseline = -paint.ascent(); // ascent() is negative
int width = (int) (paint.measureText(text) + 0.5f); // round
int height = (int) (baseline + paint.descent() + 0.5f);
if (width<1) width=1;
if (height<1) height=1;
Bitmap image = Bitmap.createBitmap(width, height, Bitmap.Config.ARGB_8888);
Canvas canvas = new Canvas(image);
canvas.drawText(text, 0, baseline, paint);