godotengine / godot

Godot Engine – Multi-platform 2D and 3D game engine
https://godotengine.org
MIT License
90.27k stars 21.04k forks source link

get_string_size() and get_wordwrap_string_size() don't recognize the tab character. #38315

Open ondesic opened 4 years ago

ondesic commented 4 years ago

Godot version: 3.2.1 OS/device including version: Windows 10 Issue description: In the TextEdit you can insert a TAB character into your text and it takes up space. However if you test the size with get_string_size() or get_wordwrap_string_size(), you will get 0.

the code get_string_size("\t\tHello") only returns the size of "Hello". the code get_wordwrap_string_size("\t\tHello\n", 100) only returns the size of "Hello" and "\n".

kopcion commented 4 years ago

I might be wrong here, but looking at the source code it seems to me that the problem might be in the font files, as there is no special handling of '\t' character. Instead, all the arithmetics is done by adding the width of consecutive chars and subtracting kerning. Also looking at the font files (godot/thirdparty/fonts/) it would seem they are provided from outside, as 'thirdparty' suggests.

If this is indeed a problem and not intended behaviour I can add something like this: image

ondesic commented 4 years ago

That would be great.

On Sun, May 10, 2020, 2:32 PM kopcion notifications@github.com wrote:

I might be wrong here, but looking at the source code it seems to me that the problem might be in the font files, as there is no special handling of '\t' character. Instead, all the arithmetics is done by adding the width of consecutive chars and subtracting kerning. Also looking at the font files (godot/thirdparty/fonts/) it would seem they are provided from outside, as 'thirdparty' suggests.

If this is indeed a problem and not intended behaviour I can add something like this: [image: image] https://user-images.githubusercontent.com/25220729/81509881-0ae7a580-930e-11ea-80da-87a5f8711c0e.png

— You are receiving this because you authored the thread. Reply to this email directly, view it on GitHub https://github.com/godotengine/godot/issues/38315#issuecomment-626385356, or unsubscribe https://github.com/notifications/unsubscribe-auth/AGNLJEWHIDRSWBQ3SKDF2CTRQ4FNRANCNFSM4MTHYENQ .