Jump to content
Welcome to the new FusionPro User Forum! ×

HELP!!! Copyfit Rule w/ Multiple Styles & Leading Issues


Recommended Posts

I have a template where there I'm using a copyfitline rule that needs some help. There are three fields with line breaks in between in one text frame (did it this way so lines would suppress if empty). I used a copyfit rule for each field with specific values for a max and min font size (using a regular copyfitting rule was making everything the same size).


The problem came with the leading; when there was a large font over a small font, the leading wasn't being adjusted (copyfitting defaults to 120% the point size regardless of the line above), so the descenders in the large line were hanging into the smaller line below it. :mad:


I changed my rule to look for descenders in the line above, find their height in point size (knowing what percentage the descenders are of the total point size) and add it to the leading of the next field.


My problem now is that if the second variable breaks to more than one line, it retains that extra leading.


What I need: I need to find a way to tell it to only apply the extra leading to the line directly beneath the large line.


What I'm thinking: searching for when the line breaks during copyfitting and telling it not to use the additional leading.


Is there a way to do that? Is there some easier way to do this that I'm not seeing? PLEASE HELP!!! Any help would be greatly appreciated. I'm going crazy.



var heading = Field("itemHeading");
var subHeading = Field("itemSubHeading");
var desc = Field("itemDescription");
var totalText;
var prevLine;
var descenders = /Q|q|y|p|g|j/
var lead = 0; //used to fix leading in copyfit

// adjust heading copyfit
heading = CopyfitLineHorizontal(heading, "Adobe Garamond Pro Bold", 65, 370, 60, 0, false);
totalText = heading;

if (subHeading != ""){
// handle subHeading copyfit
   subHeading = CopyfitLineHorizontal(subHeading, "Adobe Garamond Pro Bold", 20, 740, 16, 22, false, true); 

   totalText = totalText + "<br>" + subHeading;}
if (desc != ""){
// handle description copyfit
   desc = CopyfitLineHorizontal(desc, "Adobe Garamond Pro Bold", 14, 740, 12, 13, false, true); 
   totalText = totalText + "<br>" + desc;}

return totalText;

// Copyfiting
   // str = data field containing the string to alter
   // font = the font (put it in quotes) using the name that FusionPro recognizes
   // size = the original point size you want to use
   // width = 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.
   // maximum = the largest point size you want the text to be in (if none, put 0)
   // 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.
   // set justwidth to true for horizontal scaling, false for changing point size
   // fixLead = true if leading needs adjusting

function CopyfitLineHorizontal(str, font, size, width, minimum, maximum, justwidth, fixLead)
 var tm = new FusionProTextMeasure;
 tm.maxWidth = -1;
 if (maximum == "0"){
   maximum = 10000000;
 var newsize, retcode, i;
 var  trackInt = new Array(0, -1, -2, -3, -4, -5);

 basetags = "<f name=\"" + font + "\">";
 newsize = size;
 i = 0;

   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 <= maximum && newsize > minimum && tm.textWidth > width*100 && retcode == 0);
 // stores leading to add for next line
   if(fixLead && (prevLine.search(descenders) > -1)){
       var origLead = newsize*1.2;
       var newLead = (origLead + lead)*10;
       tags = "<leading newsize=" + newLead + ">" + tags +"</leading>";
   lead = .269*newsize;  // stores leading to add for next line
   prevLine = str;
 return tags; // + " " + tm.textWidth + " " + width*100;

Using FusionPro Desktop 7.0P1c with Windows7

Link to comment
Share on other sites

I think that all you need to do is turn on legacy leading; then you won't need to do any of this manual leading adjustment stuff. From the Variable Text Editor dialog, click "Paragraph," then "Global Settings," and check the "Use legacy line leading" box. You can remove the logic from the rule which adjusts the leading (just comment out line 65) and see how that looks.
Link to comment
Share on other sites

Thank you so much; that looks much better. I had no idea that option was there (or what it did). I feel a little silly for trying so hard to fix it, but I'm just happy to find a solution! Thanks again!
Link to comment
Share on other sites


This topic is now archived and is closed to further replies.

  • Create New...