04-24-2024 10:36 AM - edited 04-24-2024 10:47 AM
I think, if you will add small offset here, then it will work better:
(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.
04-24-2024 11:05 AM
Thank you so much for taking the time to help me out. Your insights and suggestions were very helpful.
final code:
04-24-2024 01:33 PM
FYI: If someone has provided you with a solution, you should mark their post as the solution rather than your own response. 😉
04-24-2024 03:04 PM
@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.
04-25-2024 08:32 AM
Good point! I did miss the fact that two posts were marked as a solution. I didn't even know we could do that.