mirror of
https://codeberg.org/Freeyourgadget/Gadgetbridge
synced 2025-01-15 12:17:33 +01: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:
parent
e59375242e
commit
b334773856
@ -1336,6 +1336,8 @@ public class BangleJSDeviceSupport extends AbstractBTLEDeviceSupport {
|
|||||||
float baseline = -paint.ascent(); // ascent() is negative
|
float baseline = -paint.ascent(); // ascent() is negative
|
||||||
int width = (int) (paint.measureText(text) + 0.5f); // round
|
int width = (int) (paint.measureText(text) + 0.5f); // round
|
||||||
int height = (int) (baseline + paint.descent() + 0.5f);
|
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);
|
Bitmap image = Bitmap.createBitmap(width, height, Bitmap.Config.ARGB_8888);
|
||||||
Canvas canvas = new Canvas(image);
|
Canvas canvas = new Canvas(image);
|
||||||
canvas.drawText(text, 0, baseline, paint);
|
canvas.drawText(text, 0, baseline, paint);
|
||||||
|
Loading…
x
Reference in New Issue
Block a user