Search the Community
Showing results for tags 'calculatetextextent'.
-
I have a letterhead I need the address info to be on the top right corner, but aligned left, where the end of the furthest right letter of the Address and/or Address2 lines up with the 8" mark. To compensate for this, I have set a rule that calculates how many spaces it needs to use as padding to before each line. (Feel free to point out a better way.) The below code keeps erroring out on line 52: Error: execution limit exceeded. I'm not sure why it wouldn't work. Any ideas? var frameWidth = 2; // set width of the text box (in inches) // Use TextMeasure to get the length of each company name var space = new FusionProTextMeasure; space.pointSize = "8 pt"; // set the type size space.font = "HelveticaNeue Condensed"; // set your typeface space.CalculateTextExtent(" "); space.useTags = false; var spaceWidth = space.textWidth; // Use TextMeasure to get the length of each company name var address1 = new FusionProTextMeasure; address1.pointSize = "8 pt"; // set the type size address1.font = "HelveticaNeue Condensed"; // set your typeface address1.CalculateTextExtent(Field("Address")); address1.useTags = false; var addressWidth = address1.textWidth; // Use TextMeasure to get the length of each company name var address2 = new FusionProTextMeasure; address2.pointSize = "8 pt"; // set the type size address2.font = "HelveticaNeue Condensed"; // set your typeface address2.CalculateTextExtent(Field("Address2")); address2.useTags = false; var address2Width = address2.textWidth; // Use TextMeasure to get the length of each company name var gap = new FusionProTextMeasure; gap.pointSize = "8 pt"; // set the type size gap.font = "HelveticaNeue Condensed"; // set your typeface gap.CalculateTextExtent(" • "); gap.useTags = false; var gapWidth = gap.textWidth; var i=1 var success = false while (success == false) { if (Field("Address2") != "") //if there is an address2 { if((spaceWidth*i) + addressWidth + gapWidth + address2Width >= frameWidth*7200) //if there is an address 2 and the width is greater or equal to frameWidth { success= true; //then stop looking } else i= i+1; // if there is an address 2 and the width is less than frameWidth }; if ((spaceWidth*i) + addressWidth >= frameWidth*7200) //if there is no address 2 and the width is greater than frameWidth { success= true; //then stop looking } else i= i+1; // if there is no address 2 and the width is less than frameWidth #### ERRORS OUT ON THIS LINE #### }; var result = Array(i).join('space'); return result;
- 2 replies
-
- calculatetextextent
- font
-
(and 3 more)
Tagged with: