Nicola Posted October 15, 2008 Share Posted October 15, 2008 Hello Everyone, I have used the CopyFit Line rule on a couple of templates and it has worked out great. Now I have a template that I need to use the CopyFit Line rule, but instead of using it to adjust the size of the text I was hoping that I could use it to adjust the tracking. However, I'm not sure how to revise the rule in order to accomplish this. I was hoping that maybe someone could help me revise the following rule. Thanks in advance for any help/suggestions. return CopyfitLine("", Field("Email"), fname="WFM-ScalaSans-Regular", 9, 125, 6.5, false); Link to comment Share on other sites More sharing options...
Dan Korn Posted October 15, 2008 Share Posted October 15, 2008 Hopefully our friend David Sweet won't mind me re-posting his solution from the old email user forum: http://www.mail-archive.com/fusionpro@lists.printable.com/msg00949.html If you're familiar with the CopyFitLine function, try using this custom function instead... //set justwidth to true for horizontal scaling, false for changing point size function CopyfitLineHorizontal(str, font, size, width, minimum, justwidth) { var tm = new FusionProTextMeasure; tm.maxWidth = -1; var newsize, retcode, i; var trackInt = new Array(0, -1, -2, -3, -4, -5); basetags = "<f name=\"" + font + "\">"; newsize = size; i = 0; do { tags = basetags; tags += (justwidth) ? "<setwidth " : "<z "; tags += "newsize=" + newsize + "><tracking newsize=" + trackInt[i] + ">" + str; retcode = tm.CalculateTextExtent(tags); (i < 5) ? i++ : i=5; if (tm.textWidth > width * 100) newsize -= 0.1; } while (newsize > minimum && tm.textWidth > width*100 && retcode == 0); return tags; // + " " + tm.textWidth + " " + width*100; } Then create a text rule, with tags turned on, and pass... str = data field containing the string to alterfont = the font (put it in quotes) using the name that FusionPro recognizessize = the original point size you want to usewidth = width of the text area you want to fit measured in points (72 pts = 1 in)minimum = the smallest point size you want the text to be in.justwidth = enter true if you want the text to be "narrowed" down to the "minimum" sized entered, enter false if you want the actual font size shrunk.Examples... An entry in the rule such as... return CopyfitLineHorizontal("This is an extra long string", "Arial", 10, 110, 9, true); will return a string with the height of the font still at 10, but the width narrowed slightly... '<f name="Arial"><setwidth newsize=9.8><tracking newsize=-2>This is an extra long string' A similar entry with a false value for the justwidth... return CopyfitLineHorizontal("This is an extra long string", "Arial", 10, 110, 9, false); will return a string with the whole font size "lowered" not just narrowed... '<f name="Arial"><z newsize=9.8><tracking newsize=-2>This is an extra long string' Good Luck. Link to comment Share on other sites More sharing options...
Nicola Posted October 16, 2008 Author Share Posted October 16, 2008 Hi Dan, Thanks for the post. I'll give it a try. I appreciate the quick reply. As usual your coding skills are amazing. Link to comment Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.