IMyTextSurface.MeasureStringInPixels probably doesn't work on dedicated servers

Nicholas Stanfill shared this bug 4 years ago
Outdated

I got some reports that my script is auto-sizing panels wrong and giving them a font size of infinity. I can't replicate this bug in single player. I was told this was only happening on dedicated servers and it could not be reproduced in single player. Auto-size = setting font size to perfectly fit text onto panel

My auto-sizing function divides the panel size by text size (width and height separated) and applies the smallest number as the font size. I bet the MeasureStringInPixels is returning (0, 0) and causing division by zero. My script doesn't auto-size blank panels so that's not the problem.

My script used to only work with Monospace. I had to keep variables for monospace character sizes. I would calculate a value similar to what the MeasureStringInPixels function does and use the same math to auto-size the panel. It worked 100%, I used it on dedicated servers and was never told it didn't work.

When I saw the new functions I tossed out the variables for font sizes and panel sizes then switched to your functions as it would allow any font to be auto-sizable. It works for me in single player on every LCD panel. I'm told it doesn't work on dedicated servers. Whenever I get onto a dedicated server, or start one up to test it, I will confirm my theory that MeasureStringInPixels is returning (0, 0) as the size of the text in pixels.

On a side note, it looks like IMyTextSurface.SurfaceSize and IMyTextSurface.TextureSize return the same values. While most panels work perfectly, I have to adjust the values for: corner panels, cockpit panels, and programmable block panels. I either have to note which panel I'm resizing or only make compatibility with the first provided IMyTextSurface. Could you make IMyTextSurface.TextureSize return the size of the texture the drawing surface is rendered to, like it says it is supposed to do?

Replies (2)

photo
1

[Text Size: {X:0 Y:0}, Texture Size: {X:512 Y:512}, Surface Size: {X:512 Y:512}, Blank: False]

Proved my theory. Finally found a creative dedicated server that allowed scripts and didn't require you to be a scripter or what ever the title was.

I created a debug that as you can see above returned text size as (0, 0). The text in question was:

Cobalt Ingot       0.000        No Quota
Gold Ingot         0.000        No Quota
Iron Ingot         0.000        No Quota
Magnesium Powder   0.000        No Quota
Nickel Ingot       0.000        No Quota
Platinum Ingot     0.000        No Quota
Silicon Wafer      0.000        No Quota
Silver Ingot       0.000        No Quota
Gravel             0.000        No Quota
Uranium Ingot      0.000        No Quota

photo
1

Hello, Engineer!


Thank you for your feedback! Your topic has been added between considered issues.

Please keep voting for the issue as it will help us to identify the most serious bugs.


We really appreciate your patience.


Kind Regards

Keen Software House: QA Department

photo
3

This affects many people beyond what the "I have this problem too" count would signify because most people dont go to support portals. There is a playtest going on right now. That means programmers are actively dealing with issues that crop up.


There is no excuse for this BROKEN API to not get fixed as part of the playtest. Please worry less about making "shiney new things" and worry more about fixing the deteriorated rusted issues.

photo
Leave a Comment
 
Attach a file