love.js
love.js copied to clipboard
Running love.graphics.newText on a string with a single space and getting its width returns 0
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).
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?
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.
@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.