wiremod / wire

Garry's Mod add-on that allows users to wire up components in order to make more elaborate automatic and user-controlled contraptions.
http://www.wiremod.com
Apache License 2.0
546 stars 332 forks source link

Wire text editor doesn't support non-monospaced fonts #2944

Open DerelictDrone opened 6 months ago

DerelictDrone commented 6 months ago

Describe the bug At present, attempting to use a font that isn't monospaced will cause the text editor to print text over other text.

To Reproduce Steps to reproduce the behavior:

  1. Switch font to Fixedsys or a custom system font that isn't monospaced.
  2. Open _helloworld.txt

Expected behavior The text editor should be capable of supporting fonts where certain characters are wider or slimmer than others.

Screenshots Example using the default font Fixedsys fixedsys

Example using a known monospaced custom font, Cascadia Mono cascadia mono

Test was performed with only wiremod loaded, in singleplayer, and on gm_construct.

Vurv78 commented 6 months ago

This is way too much work and would significantly bog down the editor for very little reason. So I don't see this ever happening. It's like all the trouble of supporting unicode, but with even less benefit.

I'll leave it open for other people to give their inputs for a bit.

DerelictDrone commented 6 months ago

This is way too much work and would significantly bog down the editor for very little reason. So I don't see this ever happening. It's like all the trouble of supporting unicode, but with even less benefit.

I'll leave it open for other people to give their inputs for a bit.

To me, it looks like this is mainly just a problem of trying to calculate the position of the next text draw of the same line, you can see that the @name Hello World worked properly when it all stayed one color, maybe we could switch out some of the calculations that work with constant width supplied from font with a sum of the surface.GetTextSize for successive text draws on the same line.

Though, this also affects the text cursor's position...

DerelictDrone commented 6 months ago

If the issue itself won't get fixed then the least that can be done is to remove Fixedsys from the default fonts list, so users are less likely to run into the above behavior.

cryx3001 commented 6 months ago

I also encounter this issue when I try to use a font which is not present on my system (for example the Monaco font or a custom one which does not exist). It seems to use a fallback font which is also non-monospaced. However, it seems that there is no way to check if a font actually exist or not, and no way to edit the fallback font.