espruino / Espruino

The Espruino JavaScript interpreter - Official Repo
http://www.espruino.com/
Other
2.79k stars 747 forks source link

Graphics.wrapString cuts up images in strings #2481

Closed halemmerich closed 7 months ago

halemmerich commented 7 months ago

Bangle.JS 2 2v21.69

// 16*16px 1bit
let image = atob("ABAQAX/+gAGf+a/1t+273b29vn2+fb29u9237a/1n/mAAX/+");
print(g.stringMetrics(image));
print(g.wrapString(image,8));
print(g.wrapString("Test"+image,30));

results in:

{ "width": 16, "height": 6, "unrenderableChars": false, "imageCount": 1,
  "maxImageHeight": 16 }
[
  "\0",
  "\x10",
  "\x10\1\x7F\xFE\x80\1\x9F\xF9\xAF\xF5\xB7\xED\xBB\xDD\xBD\xBD\xBE}\xBE}\xBD\xBD\xBB\xDD\xB7\xED\xAF\xF5\x9F\xF9\x80\1\x7F\xFE"
 ]
[
  "Test\0\x10\x10",
  "\1\x7F\xFE\x80\1\x9F\xF9\xAF\xF5\xB7\xED\xBB\xDD\xBD\xBD\xBE}\xBE}\xBD\xBD\xBB\xDD\xB7\xED\xAF\xF5\x9F\xF9\x80\1\x7F\xFE"
 ]
gfwilliams commented 7 months ago

Thanks for the example - I'll take a look. This is an odd one as we do have tests for splitting images in strings - I guess it's the code that tries to deal with splitting words larger than will fit on a line