String pixel width
HARMAN_icraigie
Posts: 660
Anyone tried figuring out the width of a string as presented on a UI and then elegantly truncating if it exceeds the bounds of the text field? And no, word wrap is not an option.
There's some AWT classes that might work in Duet. What about in Netlinx?
There's some AWT classes that might work in Duet. What about in Netlinx?
0
Comments
This is very slick. But with my luck here's how it would play out.
ME: "see how that works? Now the text fits."
CLIENT (yawning): "that's cool... But I don't like the font. Can I see it with several font examples?"
I actually need to implement something similar on a current project. Looking at workload this will probably take place next week. I'll open source it up on the AMX Australia GitHub and most likely roll it into the modero library. Something like: That way you can just have a an array of character widths for the font in question. If you're using multiple sizes just keep an array handy for each and pass in the appropriate one as required. You could build these each manually or construct them on system boot based on a size multiplier from an initial array.
If anyone is keen on building something together / a better a approach let me know as we can probably save each other some duplicate effort.
Not to mention there's the whole thing with Kerning and so forth which deal with the spacing between letters, their position above or below the baseline, rotation on both axis, bla bla. Each font is literally a moving target to nail down. (...as I deftly mix my metaphors)