attractplus icon indicating copy to clipboard operation
attractplus copied to clipboard

Text char_size incorrect until msg set

Open Chadnaut opened this issue 9 months ago • 1 comments

Text char_size appears to require non-empty msg to initialize char_size.

local txt = fe.add_text("", 0, 0, fe.layout.width, fe.layout.height);

txt.char_size = 20;
print(txt.char_size + "\n"); // 30 <-- wrong

txt.msg = "Sample";
print(txt.char_size + "\n"); // 20 <-- correct

txt.msg = "";
print(txt.char_size + "\n"); // 20 <-- correct

Attract-Mode Plus v3.0.8, Attract-Mode v2.7.0

Chadnaut avatar Apr 27 '24 05:04 Chadnaut

Thanks for spotting that. Here is a proposed fix https://github.com/oomek/attractplus/tree/fix/char_size I've also identified another problem with char_size value when you override the layout size and this fix tries to address that aswell.

fe.layout.width = 320;
fe.layout.height = 240;

oomek avatar Apr 27 '24 11:04 oomek

Fixed in https://github.com/oomek/attractplus/commit/f264e43f8ca493360a3ba66128682ae424944e60

oomek avatar Oct 01 '24 02:10 oomek