Expand my Community achievements bar.

Auto-adjust font size to fit

Avatar

Former Community Member
Does anyone know of a way to auto-adjust the font size of a text field to prevent scrolling? I am binding data to the field, and if the incoming xml data causes the field to scroll I would like to adjust the font size so that the text will fit in the field without scrolling.



Before anyone suggests counting the number of characters...this is not an acceptable solution because I am not using a fixed-width font.



Any ideas?
5 Replies

Avatar

Former Community Member
You can put the following line of javascript on "initialize" event of the text field. This should automatically sizing your font.



this.font.size = "0pt";

Avatar

Former Community Member
Jimmy,

I attempted to do this with no luck. Is there anything else that needs to be done? Can you provide a working example demonstrating this?

Avatar

Former Community Member
You can find an example here. Key in the text field. As you content grows, the font fize will be reduced automatically to fit the content in that text field.



http://66.34.186.88/LiveCycleSamples/.3bbd0d52.pdf

Avatar

Former Community Member
Now I see the problem. This only works with plain text. It does not work for rich text, which is what my field is set to use. Thanks for the advice.