Susan Posted August 28, 2018 Share Posted August 28, 2018 I have a rule where the line will break after the " & " when the whole line won't fit. I also want it to break after " and " since some entries use "and" instead of "&". Where would I add another variable in the rule below? // Use TextMeasure to get the length of each company name var tm = new FusionProTextMeasure; var frameWidth = 2.5; // set width of the text box (in inches) tm.pointSize = "9 pt"; // set the type size tm.font = "Chronicle Deck"; // set your typeface var str = Field("Mailing Name "); // set the field to use tm.CalculateTextExtent(str); tm.useTags = false; var tmWidth = tm.textWidth; var a tmWidth = tm.textWidth; return (tmWidth < frameWidth*7200) ? str : str.replace(" & ", " &<br>"); Quote Link to comment Share on other sites More sharing options...
Dan Korn Posted August 28, 2018 Share Posted August 28, 2018 I would replace the last line with this: return (tmWidth < frameWidth*7200) ? str : str.replace(/\b(\&|and)\b/, "$1<br>"); I would also make sure you're handling the text as tagged markup to begin with, like so: // Use TextMeasure to get the length of each company name var tm = new FusionProTextMeasure; var frameWidth = 2.5; // set width of the text box (in inches) tm.pointSize = "9 pt"; // set the type size tm.font = "Chronicle Deck"; // set your typeface var str = TaggedDataField("Mailing Name "); // set the field to use tm.CalculateTextExtent(str); var tmWidth = tm.textWidth; return (textWidth < frameWidth*7200) ? str : str.replace(/\b(\&|and)\b/, "$1<br>"); Quote Link to comment Share on other sites More sharing options...
Susan Posted August 29, 2018 Author Share Posted August 29, 2018 Thanks for your input. Quote Link to comment Share on other sites More sharing options...
Recommended Posts
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.