TEXT re-size with the amount of text

Started by kiler40, August 14, 2013, 02:01:10 PM

Previous topic - Next topic

0 Members and 1 Guest are viewing this topic.

kiler40

Hello again....
I`m full with small issues :)

Looking around the TEXT resize options in the shapesheet functions but cant find one. How to resize a text based on the number of symbols.
But it is more complex.
I want to have initial size as constant. But instead of going on the second row when i reach the end of the shape field, Is it possible the text to become smaller to fit on one row :)

It is strange request... but it keeps jump in my head again and again all day...

Surrogate

which dimension you want resize: width or height ?

kiler40

you can change both ? really ? i thought that only size in "pt"or "mm" chan be changed of the text size....

I don`t want to change shape dimensions
(the one to change shape dimensions according to the text size/amount i know hot to do :) )

aledlund

since autosize is merely the instantiation of the button on the tool bar, does the drawing size change when you select the button? It does on my system.
al

kiler40

autosize ? of tex ? sorry... didn`t understaind that..

kiler40

oh.... what was i thinking.... :( TEXT RESIZE ! I want to resize THE TEXT..... dam.... it seems i was to tired at the end of the working day... sorry

Surrogate

#6
if you want resize width of shape according to the text
Width= MAX(10 mm,TEXTWIDTH(TheText,Height))
sorry i'm Russian. may be i'm misunderstand too

kiler40

this made something like that ... but not exactly

here is visual example :)

Paul Herber

I've renamed the whole thread to save confusion.
Electronic and Electrical engineering, business and software stencils for Visio -

https://www.paulherber.co.uk/

kiler40

Ok.. I`m up to this

character.size=Width*100/TEXTWIDTH(TheText)*0.1 pt

In this case the text re-sizes with the shape and as more text you put, the smaller it becomes.
But i don`t want exactly this to happen.
I want the text to stay big, until it fills the shape. and after that to start get smaller. And most of all, not to come on 2 rows...

wapperdude

Well, you can use an "IF" statement to compare the textwidth to the width of the shape.  If the textwidth exceeds the shape width, then, apply the formula, otherwise, use fixed character size.

However, as straight forward as it may seem, there are actually two problems.  1.)  The most serious seems to be with the textwidth(TheText) function.  As you enter text, the width increases, duh, except sometimes the text unpredictably wraps to 2nd line.  So, the function above, tends to be unpredictable.  2.)  As the text is added, the textwidth increases, until smaller font size is chosen, then, the textwidth decreases.  My theory is that this dynamic behavior of (2), leads to unpredictable line wrapping of (1).  The intent of these functions was to change the shape size, not change the character size.  So, just a "user beware" warning.

Never really solved this problem satisfactorily.  It would be nice if there were an event trigger, or a "depends on" event, or perhaps the feared setatref function that would know when the amount of text has been completely entered, then, check the textwidth, and finally reduce the character size to fit.

Wapperdude
Visio 2019 Pro

wapperdude

#11
Did some additional trials...
The following formula placed in the Character size cell seems to work:  =144/(LEN(SHAPETEXT(TheText)))*1 pt.

This is based upon Arial font, with LeftMargin=RightMargin=0 pt.  The 144 is approximate scaling factor, probably changes with font face.
Also, I added the following formula to the Width cell:  =GUARD(MIN(1,TxtWidth)).  This formula limits the maximum text box size to 1.  Set it to your desired value.

If you want, you can add the INT function to make the font size strictly integer or you can use the ceiling function if you want to step the char size by specific increments.

This seems to avoid the weird behavior of line wrapping as it is based upon actual number of characters and not some hidden, derived textwidth function.

HTH
Wapperdude.
Visio 2019 Pro

kiler40

Thanks this seems to work fine.
I have small differences in text length, but it changes constantly, so this pretty much answers my question.
I`ll make some tryouts with the IF function and see what happens :)

Thanks Again.
Andrei

wapperdude

One other point to note:

The formula is only approximate since it does not take into kerning effects.  Consequently, the inaccuracy of the formula increases with the addition of text.  Fonts like Courier should show less or no effect since all letters should be of equal width.

Wapperdude
Visio 2019 Pro