Understanding the geometric length of a text string

Started by manifold1978, August 03, 2024, 10:29:15 AM

Previous topic - Next topic

0 Members and 1 Guest are viewing this topic.

manifold1978

I have a single text box on my shapes that is made up of a few bits of shape data. Manufacturer, model and quantity.

I like that it's one box instead of three as it means I can take advantage of all the space if needed, Like if you have a really long model name that would otherwise spill out of the box.

What would be nice though is, if I didn't need all the space, if I could create a line break between manufacturer and model, so it's on a different line. I'd only want to do this if there's enough space in the box to fit everything in.

For the reverse situation of the whole combined string of manufacturer/model/qty being too long to fit in the box, I wonder if I could chop the middle out and replace it with a "...".

I suppose what I'm getting at is, is there any way to understand the geometric length of a text string, and do things based on that? This would of course be different to understanding the number of characters, as characters are different sizes.

I've found various resources on resizing boxes around text, or resizing text to a fit a box here:

https://www.visguy.com/2009/05/06/top-twelve-text-tips/
https://www.visguy.com/2007/08/21/text-resizing-with-shapesheet-formulas/

But I don't think I'm quite getting to the nub of the problem.

Any pointers?

wapperdude

Haven't given this much thought, but couple things occurred to me.  If you don't mind the height of the the shape changing, then this post, reply #3, might be interesting:  https://visguy.com/vgforum/index.php?topic=9178.msg40714#msg40714

Regarding the use of ...:  that will only work on a text string, so not applicable to links.  Well, at least not directly.  But, assuming you know how many characters you can have, you could just grab a few characters from the left, add the ..., and then grab few characters from the right.  The total sum of this composite string needs to be few characters then what will cause overflow and wrapping.  Note, it doesn't matter how long the original string might be since you're just grabbing part of the front and part of the back.

Can't say I'm fond of doing this. 

Visio 2019 Pro

Browser ID: smf (possibly_robot)
Templates: 4: index (default), Display (default), GenericControls (default), GenericControls (default).
Sub templates: 6: init, html_above, body_above, main, body_below, html_below.
Language files: 4: index+Modifications.english (default), Post.english (default), Editor.english (default), Drafts.english (default).
Style sheets: 4: index.css, attachments.css, jquery.sceditor.css, responsive.css.
Hooks called: 161 (show)
Files included: 34 - 1306KB. (show)
Memory used: 1056KB.
Tokens: post-login.
Cache hits: 13: 0.00130s for 26,602 bytes (show)
Cache misses: 3: (show)
Queries used: 16.

[Show Queries]