Go Back   MarcomCentral (PTI) and FusionPro User Communities > Software-Related Talk > The JavaScript Library > Formatting Text


Thread Tools Search this Thread Display Modes
Old July 29th, 2010, 02:30 PM
teresas teresas is offline
Junior Community Member
Join Date: Jun 2010
Location: Chicago
Posts: 17
Question HELP!!! Copyfit Rule w/ Multiple Styles & Leading Issues

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.

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
Reply With Quote
Old July 29th, 2010, 05:45 PM
Dan Korn's Avatar
Dan Korn Dan Korn is offline
FusionPro Senior Engineer / Forum Moderator
Join Date: Aug 2008
Location: Chicago, IL
Posts: 4,467
Default Re: HELP!!! Copyfit Rule w/ Multiple Styles & Leading Issues

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.
Dan Korn
FusionPro Developer / JavaScript Guru / Forum Moderator
PTI Marketing Technologies | Printable | MarcomCentral

I am a not a Support engineer, and this forum is not a substitute for Support. My participation on this forum is primarily as a fellow user (and a forum moderator). I am happy to provide help and answers to questions when I can; however, there is no guarantee that I, or anyone else on this forum, will be able to answer all questions or fix any problems. If I ask for files to clarify an issue, I might not be able to look at them personally. I am not able to answer private messages, emails, or phone calls unless they go through proper Support channels. Please direct any sales or pricing questions to your salesperson or inquiries@marcom.com.

Complex template-building questions, as well as all installation and font questions or problems, should be directed to FusionProSupport@marcom.com. Paid consulting work may be required to fulfill your template-building needs.

This is a publicly viewable forum. Please DO NOT post fonts, or other proprietary content, to this forum. Also, please DO NOT post any "live" data with real names, addresses, or any other personal, private, or confidential data.

Please include the specific versions of FusionPro, Acrobat, and your operating system in any problem reports or help requests. I recommend putting this information in your forum signature. Please also check your composition log (.msg) file for relevant error or warning messages.

Please post questions specific to the MarcomCentral Enterprise and Web-to-Print applications in the MarcomCentral forum. Click here to request access. Or contact your Business Relationship Manager (BRM/CPM) for assistance.

Please direct any questions specific to EFI's Digital StoreFront (DSF) to EFI support.

How To Ask Questions The Smart Way

The correct spellings are JavaScript, FusionPro, and MarcomCentral (each with two capital letters and no spaces). Acceptable abbreviations are JS, FP, and MC (or MCC). There is no "S" at the end of "Expression" or "Printable"! The name of the product is FusionPro, not "Fusion". "Java" is not is not the same as JavaScript.

Check out the JavaScript Guide and JavaScript Reference! FusionPro 8.0 and newer use JavaScript 1.7. Older versions use JavaScript 1.5.

return "KbwbTdsjqu!spdlt\"".replace(/./g,function(w){return String.fromCharCode(w.charCodeAt()-1)});
Reply With Quote
Old July 30th, 2010, 06:39 AM
teresas teresas is offline
Junior Community Member
Join Date: Jun 2010
Location: Chicago
Posts: 17
Default Re: HELP!!! Copyfit Rule w/ Multiple Styles & Leading Issues

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!
Reply With Quote

copyfit, leading

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump

All times are GMT -7. The time now is 08:18 AM.

Powered by vBulletin® Version 3.8.4
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
(c) 2011, PTI Marketing Technologies™, Inc.