LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Bug in Method String Class - Byte Offset from Point

Solved!
Go to solution

I think, if you will add small offset here, then it will work better:

Screenshot 2024-04-24 17.28.29.png

(at least for me). This offset could be dependent on the font's size.


When justified to the right, it should not be a problem (because you can get the width of the control), but will require "inverting" the computation (just reversing the string), and going from right to left character by character (I think so, because you can't get coordinate of the leftmost char). Such a trivial computation with offsets and indexes usually "scrambles" my brain.

 

And just one more thing. May be for better accuracy you need to iterate over string subsets. Currently it works over single chars — "1", "2", "3" and so on, but its not guaranteed that chars displayed without gaps and overlaps, so if you will go over "1", then "12", then "123" and so on, then it will be more accurate if you have string with letters and, for example letters "A" and "V" usually closer together because you may have kerning pairs  like "AV". But this needs to be checked with your particular font and string.

Message 11 of 15
(101 Views)
Solution
Accepted by topic author maxnoder1995

Thank you so much for taking the time to help me out. Your insights and suggestions were very helpful.


final code:

Message 12 of 15
(89 Views)

FYI: If someone has provided you with a solution, you should mark their post as the solution rather than your own response.  😉

LabVIEW Pro Dev & Measurement Studio Pro (VS Pro) 2019 - Unfortunately now moving back to C#, .NET, Python due to forced change to subscription model by NI. 8^{
0 Kudos
Message 13 of 15
(72 Views)

@NIquist wrote:

FYI: If someone has provided you with a solution, you should mark their post as the solution rather than your own response.  😉


I think it's fully okay here because my response was just an idea and example on how to do this, and based on this idea, the complete solution has been developed and shared. As result here two responses are marked as a solution — my draft and author's final, and both are true solutions.

Message 14 of 15
(62 Views)

Good point!  I did miss the fact that two posts were marked as a solution.  I didn't even know we could do that.

 

 

LabVIEW Pro Dev & Measurement Studio Pro (VS Pro) 2019 - Unfortunately now moving back to C#, .NET, Python due to forced change to subscription model by NI. 8^{
0 Kudos
Message 15 of 15
(42 Views)