oomek / attractplus

Attract-Mode Plus
GNU General Public License v3.0
46 stars 16 forks source link

Text char_size incorrect until msg set #67

Closed Chadnaut closed 3 weeks ago

Chadnaut commented 6 months ago

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

oomek commented 6 months ago

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 commented 3 weeks ago

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