05-23-2017 01:13 PM
05-23-2017 01:17 PM
Graphics and Sound >>> Picture Functions >>> Get Text Rect.vi will return the size in pixel for the text you specify and the font you specify.
Ben
05-23-2017 01:25 PM
05-23-2017 01:29 PM
@ATE-EGNE wrote:
Ok, is there a reverse of this, ...
Not that I know.
Ben
05-23-2017 02:34 PM - edited 05-23-2017 02:43 PM
Can you try a few different sizes? I'm thinking there is a direct formula that would take you from font size to pixel size. Like Font size * X + Y = pixel size.
Where X is a "scaling factor" and Y might be some constant add-on such as for borders in string or numeric control.
Quick experiment on a Modern Numeric. I'm getting font size + 25 for any font size 5 or larger. For a Modern string, it seems to be the same.
05-23-2017 02:52 PM
@RavensFan wrote:
Can you try a few different sizes? I'm thinking there is a direct formula that would take you from font size to pixel size. Like Font size * X + Y = pixel size.
Where X is a "scaling factor" and Y might be some constant add-on such as for borders in string or numeric control.
Quick experiment on a Modern Numeric. I'm getting font size + 25 for any font size 5 or larger. For a Modern string, it seems to be the same.
Hide the label?
Will the math change for different system settings and fonts?
Strings of fixed width fonts will be linear but non-fixed width fonts?
Ben
05-23-2017 03:11 PM - edited 05-23-2017 03:13 PM
Some good points Ben.
Hiding the label made it only + 10.
I'm not sure if changing the font actually changed anything. It didn't seem to for the couple of fonts I tried.
Width shouldn't matter whether fixed width or not.
At least not for height which was how I interpreted the original question based on another post by the user on the topic. Change size of an object in an array
For width, then certainly the amount of characters in a string will be important whether they are fixed width or not.
Assuming it is only height, the OP shouldn't rely on my numbers, but run similar tests on his own.
05-23-2017 03:29 PM - edited 05-23-2017 03:37 PM
05-23-2017 03:35 PM
For width, then certainly the amount of characters in a string will be important whether they are fixed width or not.
Assuming it is only height, the OP shouldn't rely on my numbers, but run similar tests on his own.
I was hoping that I can get this to work as a general case so I'd really like to get LabVIEW to solve for the font size as it could vary greatly depending on the number of elements I'm working with at a given time.
Also, I will need to be worried about the width as well as multiple lines, so using the get text rect.vi is a good catch all.
05-23-2017 05:22 PM
I threw this together, so it's not perfectly tailored to solve your whole problem, but if you can follow what I'm doing, it may get you an answer you can work with. It's a little hackish, definitely. Hope it helps you find the right path, though!
The line down the middle just separates the first part from the second part. This doesn't actually run without problems; you'd have to enforce data flow and you'd probably want to find the longest element of your array first and test against that, but then you'd have your worst case scenario so you could safely use that for your font size and know that your other elements would fit nicely.