Jump to content

Wrap copy if over so many letters


Tattoued

Recommended Posts

I tried to search forums but cannot find my answer so apologies if it's out there and I didn't see it!

 

I have a variable data field where the name or company name is sometimes very short or sometimes pretty long. I'd like to be able to have the size adjust accordingly (without going TOO large), or wrap on two lines if necessary. Say I have a field called "vdata". I imagine I'd do something like if vdata is more than 50 characters, then wrap, else leave on one line, along with some other copyfit command that will adjust the size of the type so it looks decent without going too large on the short names? Thanks!

Link to comment
Share on other sites

Although probably not going to give you the best result and I am a novice when it comes to code, here is a suggestion. It just breaks your text into lines of about 50 characters. Also, don't forget to click on the "Treat ... as tagged text" checkbox.:

var vdata = "Say I have a field called 'vdata'. I imagine I'd do something like if vdata is more than 50 characters, then wrap, else leave on one line, along with some other copyfit command that will adjust the size of the type so it looks decent without going too large on the short names?";

var newstring="";

var characters=50;

textstart=0;

textend=characters;

if(Len(vdata)>characters)

{

for (aloop=1;aloop<vdata.length/characters;aloop++)

{

breakpos = vdata.indexOf(" ",textend);

textamount = breakpos-textstart;

newstring = newstring + vdata.substr(textstart, textamount)+"<br />";

textstart=breakpos+1;

textend=(aloop+1)*characters;

}

newstring = newstring + vdata.substr(textstart, vdata.length-breakpos);

}

return newstring;

 

Now wait while someone amazingly converts this into a single line of regex :)

 

The reducing and enlarging of text is up to the settings in FusionPro. You can accept the default or override and there are plenty of examples in the forum.

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...