Davidobot / love.js

LÖVE ported to the web using Emscripten, updated to the latest Emscripten and LÖVE (v11.5)
MIT License
605 stars 27 forks source link

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

Open oatmealine opened 2 years ago

oatmealine commented 2 years ago

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).

kristinalustig commented 1 year ago

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?

alexjgriffith commented 5 months ago

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.