-
• #2
Thanks - I'm looking into this now. That code works fine on the Linux build so all the automated tests passed.
If you do
g.setFontAlign(0,0,0);
then it'll work, but all text is center-aligned. -
• #3
Ok, now fixed in GitHub. Turns out GCC's handling of signed bit fields seems to be broken (or at the very least different) on non-x86 platforms. I never noticed because in my tests on real hardware I'd been using
g.setFontAlign
.I'll push a 1v99 version in the next hour or so.
-
• #4
Thanks! looking forward to update.
-
• #5
I flashed via the web IDE to 1v99 and seems like the problem persists (still got empty buffer like the above example). On another test on an 8x8 neopixel
leds.setFontAlign(0,0,0); leds.drawString("1");
actually draws the "1" character at x:-2 and y:-2, so not centered.
-
• #6
Which board are you using? I just tried here on a Pixl and also a Pico and it seems ok:
>var g = Graphics.createArrayBuffer(8, 8, 1); =Graphics: { "buffer": new ArrayBuffer(8) } >g.drawString("X"); =undefined >g.buffer.toString() ="5,5,2,5,5,0,0,0"
I'm not quite sure I understand about the centering - the default text is normally 4x5 characters so -2,-2 sounds ok, perhaps 1 pixel off depending how you choose to round.
-
• #7
I see - I might misunderstood how the fontAlign works. I am using the original espruino board.
-
• #8
I just tried an original Espruino board and the code I posted above does work for me. Is there something else that isn't working for you?
Have a look at http://www.espruino.com/Reference#l_Graphics_setFontAlign
setFontAlign is new, but basically it defines how subsequent calls to
drawString(txt,x,y)
will align the text tox,y
. In your example you've left x&y out, so it'll be using 0,0 as the centre, hence the apparent-2,-2
.You probably wanted:
leds.setFontAlign(0,0,0); leds.drawString("1",leds.getWidth()/2,leds.getHeight()/2);
-
• #9
Thanks Gordon - strange, I’m getting the empty buffer still. I’ll try again after work and update.
-
• #10
Looks like I was still on 1v98 when I tried the second time around. Confirmed on 1v99 that issue is fixed. Thanks!
I reflashed to 1v98 and drawString seems to not work:
tried fillRect works fine:
Am I missing anything?
Thanks!