Go Back   MarcomCentral (PTI) and FusionPro User Communities > Support > Fonts

Notices

Reply
 
Thread Tools Search this Thread Display Modes
  #1  
Old March 31st, 2016, 01:43 PM
jmerrick0657 jmerrick0657 is offline
Junior Community Member
 
Join Date: Nov 2013
Posts: 33
Default Copyfitting Issue

I'm having trouble with some copyfitting. Here is the code I am using:

var StaticPart = ""; //This text will not copyfit.
var DynamicPart = Rule("DetermineLogoLines"); //This text will copyfit.
var TextFont = "Formata Light";
var FontSize = 7.5;
var MinFontSize = 1;
var AdjustWidthOnly = false;

if (Rule("DetermineLogoLines") != "")
return CopyfitLine(StaticPart,DynamicPart,TextFont,FontSi ze, Round(Rule("LogoHeadingLength") / 100,0), MinFontSize, AdjustWidthOnly);
else
return "";

Based on the length of the first line of text, a right aligned tab is set, then the second two lines of text are copyfitted from the edge of the box to the point where the tab is.

This seems to be working when there is little or no copyfitting required. However when it needs to copyfit, the minimum font size is always returned.
Reply With Quote
  #2  
Old March 31st, 2016, 01:58 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,293
Default Re: Copyfitting Issue

It's almost impossible to analyze the rule and figure out how to improve it without having the rest of the job to reproduce what it's doing.
__________________
Dan Korn
FusionPro Developer / JavaScript Guru / Forum Moderator
PTI Marketing Technologies | Printable | MarcomCentral
LinkedIn

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
  #3  
Old March 31st, 2016, 02:03 PM
jmerrick0657 jmerrick0657 is offline
Junior Community Member
 
Join Date: Nov 2013
Posts: 33
Default Re: Copyfitting Issue

Oh, ok. If you would like to take a look at the job I have attached the zip file. I did change the copyfit rule to measure the length of the text field and divide by 99 instead of 100. That seems to work if there is not that much copyfitting.

Thanks,
Jake
Attached Files
File Type: zip Fusion Pro.zip (810.6 KB, 11 views)
Reply With Quote
  #4  
Old March 31st, 2016, 04:16 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,293
Default Re: Copyfitting Issue

Quote:
Originally Posted by jmerrick0657 View Post
Oh, ok. If you would like to take a look at the job I have attached the zip file. I did change the copyfit rule to measure the length of the text field and divide by 99 instead of 100. That seems to work if there is not that much copyfitting.
Thanks. The job is a lot more complicated than I expected. It's very cleverly done, but I found it very difficult to trace through all of the different rules calling other rules (especially since the rules all have similar names).

I found it much easier to grok by combining all the logic into a single rule, with some of the code simplified, and a bit of debugging code added:
Code:
var Debug = [];
if (!Field("LogoHeading"))
    return "";
    
var TextFont = "Arial";
    
// DisplayLogoHeading
var frameWidth = FindTextFrame("LogoBox").GetSettableTextWidth() / 100;
var FontSize = 17.25;
var MinFontSize = 6;
var DisplayLogoHeading = CopyfitLine("", Field("LogoHeading"), TextFont, FontSize, frameWidth, MinFontSize);
Debug.push("DisplayLogoHeading is:\n" + DisplayLogoHeading);

// LogoHeadingLength
var TM = new FusionProTextMeasure;
TM.CalculateTextExtent(DisplayLogoHeading);
var LogoHeadingLength = TM.textWidth;
Debug.push("LogoHeadingLength is: " + LogoHeadingLength);

// DetermineLogoLines
var LogoLines = [Field("Logo1"), Field("Logo2")].filter(String).join('<br><t>');
if (!LogoLines.length)
  return "";
LogoLines = '<p br=false tabstops="0;' + LogoHeadingLength + ',Right,.,"><color name="PANTONE 7540 C" shading=70><t>' + LogoLines + '</color>';
Debug.push("DisplayLogoHeading is:\n" + LogoLines);

var frameWidth = LogoHeadingLength / 99;
var FontSize = 9.25;
var MinFontSize = 1;
var result = CopyfitLine("", LogoLines, TextFont, FontSize, frameWidth, MinFontSize);
Debug.push("result is:\n" + result);
if (FusionPro.inValidation)
    return Debug.join("\n\n");

return result;
Note that I'm using Arial because I don't have your fonts. (Please don't post proprietary fonts to this public forum.)

This allowed me to click Validate with the above code, then change the 99 to 100, and Validate again, and compare the results.

I think what's happening is that FusionPro has trouble setting the text to fit aligned to a tab stop that's exactly as wide as the text. It needs just the tiniest bit of "wiggle room." I got it to work by, instead of dividing by 99, subtracting 1 (hundredth of a point) from the calculated LogoHeadingLength to set the tab stop width. So my final rule is this:
Code:
var Debug = [];
if (!Field("LogoHeading"))
    return "";
    
var TextFont = "Arial";
    
// DisplayLogoHeading
var DisplayLogoHeading = Rule("DisplayLogoHeading");
Debug.push("DisplayLogoHeading is:\n" + DisplayLogoHeading);

// LogoHeadingLength
var TM = new FusionProTextMeasure;
TM.CalculateTextExtent(DisplayLogoHeading);
var LogoHeadingLength = TM.textWidth;
Debug.push("LogoHeadingLength is: " + LogoHeadingLength);

// DetermineLogoLines
var LogoLines = [Field("Logo1"), Field("Logo2")].filter(String).join('<br><t>');
if (!LogoLines.length)
  return "";
LogoLines = '<p br=false tabstops="0;' + (LogoHeadingLength - 1) + ',Right,.,"><color name="PANTONE 7540 C" shading=70><t>' + LogoLines + '</color>';
Debug.push("DisplayLogoHeading is:\n" + LogoLines);

var frameWidth = LogoHeadingLength / 100;
var FontSize = 9.25;
var MinFontSize = 1;
var result = CopyfitLine("", LogoLines, TextFont, FontSize, frameWidth, MinFontSize);
Debug.push("result is:\n" + result);
if (FusionPro.inValidation)
    return Debug.join("\n\n");

return result;
The other thing that I think isn't quite right about this is that the last call to the CopyfitLine function is actually measuring two lines of text, which, as its name ("CopyfitLine", singular) suggests, isn't exactly what it was designed to do. But it works anyway because it just examines the width of the full text, which is going to be the widest line's width.

Finally, keep in mind that most things that you do with tabs can also be done with tables. So this could be done by defining a table with a single cell, like so:
Code:
var Debug = [];
if (!Field("LogoHeading"))
    return "";
    
var TextFont = "Arial";
    
// DisplayLogoHeading
var DisplayLogoHeading = Rule("DisplayLogoHeading");
Debug.push("DisplayLogoHeading is:\n" + DisplayLogoHeading);

// LogoHeadingLength
var TM = new FusionProTextMeasure;
TM.CalculateTextExtent(DisplayLogoHeading);
var LogoHeadingLength = TM.textWidth;
Debug.push("LogoHeadingLength is: " + LogoHeadingLength);

// DetermineLogoLines
var LogoLines = [Field("Logo1"), Field("Logo2")].filter(String).join('<br><t>');
if (!LogoLines.length)
  return "";
LogoLines = '<color name="PANTONE 7540 C" shading=70>' + LogoLines + '</color>';
Debug.push("DisplayLogoHeading is:\n" + LogoLines);

var frameWidth = LogoHeadingLength / 100;
var FontSize = 9.25;
var MinFontSize = 1;
var content = CopyfitLine("", LogoLines, TextFont, FontSize, frameWidth, MinFontSize);
Debug.push("Content is:\n" + content);

var table = new FPTable;
table.AddColumn(LogoHeadingLength);
var cell = table.AddRow().Cells[0];
cell.HAlign = "Right";
cell.Content = content;
cell.Margins = { Top:0, Bottom:0, Left:0, Right:0 };
var result = table.MakeTags();

Debug.push("result is:\n" + result);
if (FusionPro.inValidation)
    return Debug.join("\n\n");

return result;
No "wiggle room" necessary!
__________________
Dan Korn
FusionPro Developer / JavaScript Guru / Forum Moderator
PTI Marketing Technologies | Printable | MarcomCentral
LinkedIn

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
  #5  
Old April 1st, 2016, 08:57 AM
jmerrick0657 jmerrick0657 is offline
Junior Community Member
 
Join Date: Nov 2013
Posts: 33
Default Re: Copyfitting Issue

Dan,
Thanks a lot! That is perfect. I never thought about using tables. I really don't have the greatest grasp of JavaScript and mostly hobble the code together.

Thanks again for the help,
Jake
Reply With Quote
Reply

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 01:39 PM.


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