love.js icon indicating copy to clipboard operation
love.js copied to clipboard

Running love.graphics.newText on a string with a single space and getting its width returns 0

Open oatmealine opened this issue 3 years ago • 2 comments

See title:

local text = love.graphics.newText(love.graphics.getFont(), ' ')
print(text:getWidth()) --> 0

This does not replicate the behavior when using Font:getWidth in love.js or Text:getWidth natively, both of which return 8 (or whatever the size of a space in the font is).

oatmealine avatar Aug 09 '22 15:08 oatmealine

Possibly related - a game I'm working on has text input, and the text input constantly strips out any spaces in the web version (not other versions). Could it be that the problem isn't with getWidth but instead with how spaces are treated in general?

kristinalustig avatar Nov 29 '22 20:11 kristinalustig

Which version of love.js are you running? On the 11.4 version compiled with the compatibility flag I get the same width for a space both on the web version and the native version.

SCROT-Apr17::213901

@kristinalustig Concerning spaces captured using the textinput handler, love.js overwrites the browsers default use of spaces and arrow keys (in index.html). Note that space is still captured in the keypressed handler.

alexjgriffith avatar Apr 18 '24 02:04 alexjgriffith