Shrink-to-fit text default font size | Community
Skip to main content
AwesomeNick-UYn
Level 2
July 12, 2016
Solved

Shrink-to-fit text default font size

  • July 12, 2016
  • 13 replies
  • 15732 views

Hi folks -

I'm looking for some help with the shrink-to-fit functionality. Is there a method to set the default starting font to something other than size 12 for the shrink-to-fit function?

This post is no longer active and is closed to new replies. Need help? Start a new post to ask your question.
Best answer by SI_MSD7

Use a multi-line text field (allowing Multiple lines) and set the field value to "0". You wont be able to control the starting font size, but the text will shrink when it reaches the end of the field (similar to AcroForms when the font size is set to Auto).

Note: I believe this requires saving as a Dynamic form vs Static.

13 replies

radzmar
Level 10
July 13, 2016

I don't think so.

SI_MSD7Accepted solution
Level 6
July 18, 2016

Use a multi-line text field (allowing Multiple lines) and set the field value to "0". You wont be able to control the starting font size, but the text will shrink when it reaches the end of the field (similar to AcroForms when the font size is set to Auto).

Note: I believe this requires saving as a Dynamic form vs Static.

AwesomeNick-UYn
Level 2
July 26, 2016

Thanks for the posts but no one has answered the question conclusively yet.

Level 6
July 26, 2016

The solution I provided above works. I've used it several times.

AwesomeNick-UYn
Level 2
August 19, 2016

I also stumbled into the "allow multiple line" as a partial fix. While checking that option does not let you control the starting font size, it does shrink the starting font size a bit making the font look more appropriate with forms designed in the 10-11 font size range.

equipment-studi
Level 2
August 20, 2016

Guys,

I think you all (except radzmar) didn't caught the point. He don't want to know, how the "auto-text-size" works. That's what he knows.

He want to know, wether there is any possiblity to change the default font size, before LCD starts to shrink.

Example: You want to have similar pages with the same font size (e.g. 8pt -> not 12pt as it is), but if any page's space isn't sufficient, he wants to auto-shrink the text until it fits.

The easy answer would be no, as radzmar said before.

I'm looking for that function for more than a half year now, without any solution. I think there might be a chance, to write a special JavaScript or XML code into your formular, to do that. But I really don't know, how that should look like. Maybe a JavaScript for the "exit" which checks, wether your space isn't sufficient and than switches over to "auto-shrink".

I could envision that there is some piece of code, which does that. But I'm really now JavaScript writer :-D

And there are just a handfull of people who knows how to write a good JavaScript within LCD.

Kindly regards,

Florian

mattiaswallin
Level 3
August 22, 2016

I've been looking for a good answer for this aswell.

And as Radzmar answered, from what I have found it seem that the answer to your question is "No, any such method does not exist".

Personally I tried to work around it by having a check on the change event and if the text field overflows I would lower the font etc. However, the font size of the field doesn't update "immediately"/dynamically when changing the font for the field but rather it updated when the field was exited (even though some effort to force a layout update etc. and the scripting/change of font taking place on the change event). My final solution ended up being something similar to what Florian described above.

(on change event)

if(xfa.event.newText.length == 24){

    this.font.size = "0pt";

}

This was for a field with the standard font size of 10pt from the start, and the 24 character limit I just found as an estimate of the number of characters that would fill up the text field. So now it would keep the font that I want until it overflows, in that case the user just keeps writing and after that the font size is shrunk to make the text fit.

I'd like to believe there is a better way to do it, however this is at least something that works.

equipment-studi
Level 2
August 22, 2016

Hi mattiaswallin,

great piece of code for that! I worked with the length-event in case of an overflow. But this is cool. Only thing is the problem with differing fonts. But I think RTF and "auto size" are mutually exclusive right? So there is no problem at all.

Great code! Will use that too, if you permit ;-)

Kindly regards,

Florian

AwesomeNick-UYn
Level 2
August 22, 2016

Flrorian - I get what Radzmar said. What I'm trying to convey here is that if you set the box to allow multiple lines, as both I and SI_MSD7 said, it will shrink the text slightly to give you a smaller starting text size.

equipment-studi
Level 2
August 22, 2016

As far as I know, AwesomeNick, multilining does not give control about the text size before shrinking. Just gives any standard size (12 I think?) but not the option to set a size and after that doesn't fit, shrink.

Kindly regards,

Florian