String pixel width
HARMAN_icraigie
Technical Trainer II, Harman Professional University
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?
Comments
-
Don’t know if it’s an option for you or not but I’ve used a fixed-width font in the past to determine the length of the text on a button to do things like creating a stock ticker and a scrolling marquee.
-
If a fixed width doesn't suit the design and you are just using standard ASCII set yourself up a 255 element array. Place the rendered width of each character in there then iterate across your string until you reach the character that exceeds the element width - 1. It would be a pain to set up initially but once you've done a font once you could use it across any other systems.
-
If a fixed width doesn't suit the design and you are just using standard ASCII set yourself up a 255 element array. Place the rendered width of each character in there then iterate across your string until you reach the character that exceeds the element width - 1. It would be a pain to set up initially but once you've done a font once you could use it across any other systems.
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?" -
Something along those lines. I had in mind maybe factoring in a font size multipier as well.If a fixed width doesn't suit the design and you are just using standard ASCII set yourself up a 255 element array. Place the rendered width of each character in there then iterate across your string until you reach the character that exceeds the element width - 1. It would be a pain to set up initially but once you've done a font once you could use it across any other systems.
-
I not a typography expert by any means, however, I think different type faces can render characters differently depending on the size, i.e. it's not a linear mapping. Depending on how accurate you want to get with this it may be sufficient for your purposes though.
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:truncateToWidth(char text[], integer width, integer characterWidths[255])
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. -
I not a typography expert by any means, however, I think different type faces can render characters differently depending on the size, i.e. it's not a linear mapping. Depending on how accurate you want to get with this it may be sufficient for your purposes though.
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:truncateToWidth(char text[], integer width, integer characterWidths[255])
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)
Categories
- All Categories
- 2.5K AMX General Discussion
- 922 AMX Technical Discussion
- 514 AMX Hardware
- 502 AMX Control Products
- 3 AMX Video Distribution Products
- 9 AMX Networked AV (SVSI) Products
- AMX Workspace & Collaboration Products
- 3.4K AMX Software
- 151 AMX Resource Management Suite Software
- 386 AMX Design Tools
- 2.4K NetLinx Studio
- 135 Duet/Cafe Duet
- 248 NetLinx Modules & Duet Modules
- 57 AMX RPM Forum
- 228 MODPEDIA - The Public Repository of Modules for Everyone
- 943 AMX Specialty Forums
- 2.6K AMXForums Archive
- 2.6K AMXForums Archive Threads
- 1.5K AMX Hardware
- 432 AMX Applications and Solutions
- 249 Residential Forum
- 182 Tips and Tricks
- 146 AMX Website/Forums