Go Back   MarcomCentral (PTI) and FusionPro User Communities > Support > Issues, Questions, Etc.

Notices

Reply
 
Thread Tools Search this Thread Display Modes
  #1  
Old June 4th, 2014, 09:36 AM
sandig@customprinters.com sandig@customprinters.com is offline
Regular Contributor
 
Join Date: Feb 2010
Posts: 62
Default copyfit by textwidth and then by font size

I need to copyfit a line first by horizontally scaling it If it exceeds max scaling amount, then I need to reduce the font size.
Copy needs to fit onto one line.
There would be several lines of text in the frame, the copyfitting can only apply to specifc lines of text.

So far, I've come up with this, but it does not work. It only horiz scales.

var thirdname = ToUpper(Field("Available third line"))

//apply horiz scaling to font at 2100.
var thirdnameWidth = CopyfitLineWithMagnifyTag('<f name="Pluto Bold">' + '<z newsize=221>' +thirdname, 2100);

//calculate the horizwidth of thirdnamewidth
TM = new FusionProTextMeasure;
TM.CalculateTextExtent(thirdnameWidth);

//if width is greater than 2100, return horizscaled type and reduce font size to fit frame width of 1400

if (TM.textWidth > 2100)

return CopyfitLineBasic(thirdnameWidth, "Pluto Bold", 221, 1400, 50, "fontSize");
else return thirdnameWidth;
Reply With Quote
  #2  
Old June 5th, 2014, 08:53 AM
Dan Korn's Avatar
Dan Korn Dan Korn is offline
FusionPro Senior Engineer / Forum Moderator
 
Join Date: Aug 2008
Location: Chicago, IL
Posts: 4,312
Default Re: copyfit by textwidth and then by font size

What does the CopyfitLineBasic function do? Can you post that? Also, I think I know the CopyfitLineWithMagnifyTag function, but you should post that too, in case there were changes to it.
__________________
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 June 5th, 2014, 09:40 AM
sandig@customprinters.com sandig@customprinters.com is offline
Regular Contributor
 
Join Date: Feb 2010
Posts: 62
Default Re: copyfit by textwidth and then by font size

Here are the two functions, and attached a FP 8.2.7 PDF file.
see RULE_copyfit_3rdname_widthANDsize

function CopyfitLineBasic(lineContent, font, defaultSize, maxWidth, minimumSize, copyfitBy)

{
var tm = new FusionProTextMeasure;

tm.maxWidth = -1;
var newsize, retcode;
basetags = "<f name=\"" + font + "\">";
newsize = defaultSize;

do

{
tags = basetags;

if (copyfitBy == "fontSize")
{
tags += "<z ";
}
else if (copyfitBy == "fontWidth")
{
tags += '<setwidth "';
}
tags += "newsize=" + newsize + ">" + lineContent;
retcode = tm.CalculateTextExtent(tags);

if (tm.textWidth > maxWidth * 100)

newsize -= 0.1;

} while (newsize > minimumSize && tm.textWidth > maxWidth*100 && retcode == 0);

return tags; // + " " + tm.textWidth + " " + maxWidth*100;

}
Attached Files
File Type: zip CopyfitbyLineMagnifytest.zip (9.88 MB, 3 views)
Reply With Quote
  #4  
Old June 5th, 2014, 09:43 AM
sandig@customprinters.com sandig@customprinters.com is offline
Regular Contributor
 
Join Date: Feb 2010
Posts: 62
Default Re: copyfit by textwidth and then by font size

Here is the 2nd function

function CopyfitLineWithMagnifyTag(line, widthInPoints, AllowToExpand)
{
var tm = new FusionProTextMeasure;
tm.CalculateTextExtent(line);
if (tm.messages)
ReportError("CopyfitMagnifyLine: " + tm.messages);

if (tm.textWidth < widthInPoints*100 && !AllowToExpand)
return line;

var factor = Round(widthInPoints / tm.textWidth * 10000, 0) - 1;
return "<magnify type=setwidth factor=" + factor + ">" +
line + "</magnify>";
}
Reply With Quote
  #5  
Old June 5th, 2014, 10:00 AM
Dan Korn's Avatar
Dan Korn Dan Korn is offline
FusionPro Senior Engineer / Forum Moderator
 
Join Date: Aug 2008
Location: Chicago, IL
Posts: 4,312
Default Re: copyfit by textwidth and then by font size

Quote:
Originally Posted by sandig@customprinters.com View Post
Here are the two functions, and attached a FP 8.2.7 PDF file.
I appreciate you attaching the collected job. Unfortunately, though, none of the rules work for me at all since I don't have the font "Pluto Bold" installed. Please do not attach fonts to this public forum, though. I'll see if I can figure it out using standard fonts.
__________________
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
  #6  
Old June 6th, 2014, 10:10 AM
Dan Korn's Avatar
Dan Korn Dan Korn is offline
FusionPro Senior Engineer / Forum Moderator
 
Join Date: Aug 2008
Location: Chicago, IL
Posts: 4,312
Default Re: copyfit by textwidth and then by font size

Okay, so I see a few problems. First, you're not specifying the same "width" to both the CopyfitLineWithMagnifyTag and CopyfitLineBasic functions.

You're also getting the units wrong. The main problem is here:
Code:
if (TM.textWidth > 2100) // wrong, units are different!
The "2100" is supposed to be the frame width in points. But TM.textWidth is in hundredths of points. So to compare those, you either need to divide TM.textWidth by 100 to get that in points, or multiply the 2100 by 100 to get that in hundredths of points. So change that line to this:
Code:
if (TM.textWidth > 210000) // compare as hundredths of points
And things should work. (Although an even better way to do this, instead of hard-coding the width of the frame, is to check the "Re-evaluate this rule for every text flow" box, and get the frame width programatically.)

However, with that problem fixed, you should see the other problem, which is that that condition is always true, because CopyfitLineWithMagnifyTag always shrinks the text enough to fit, so you never get to the call to CopyfitLineBasic (the "then by font size" part).

In your original post, you say:
Quote:
Originally Posted by sandig@customprinters.com View Post
I need to copyfit a line first by horizontally scaling it If it exceeds max scaling amount, then I need to reduce the font size.
But what is this "max scaling amount," and where is it specified in the rule? Although I think what you really mean is a "minimum scaling factor," e.g. "Scale no less than 50 percent." The CopyfitLineWithMagnifyTag function doesn't have any concept of a "minimum scaling factor." One could be added, and I could probably help with that as well, but I think you should go back and try the changes I already suggested and see if those give you the results you want.
__________________
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
  #7  
Old June 9th, 2014, 06:58 AM
sandig@customprinters.com sandig@customprinters.com is offline
Regular Contributor
 
Join Date: Feb 2010
Posts: 62
Default Re: copyfit by textwidth and then by font size

Thank you Dan. I appreciate you expertise.
I adjusted the rule.
I get the scaled size.
I do not get the font to reduce size as needed.

RULE_copyfit_3rdname_widthANDsize

if (Field("Available third line") !="")
{
var thirdname = ToUpper(Field("Available third line"))
var thirdnameWidth = CopyfitLineWithMagnifyTag('<f name="Pluto Bold">' +
'<z newsize=221>' +thirdname, 2100);
//The frame with is actually 1400. I do not want it to scale that much, so I made the frame widith in the rule 2100


TM = new FusionProTextMeasure;
TM.CalculateTextExtent(thirdnameWidth);

if (TM.textWidth > 210000) // compare as hundredths of points

return CopyfitLineBasic(thirdnameWidth, "Pluto Bold", 221, 1400, 50, "fontSize");
else return thirdnameWidth;
Attached Files
File Type: pdf CopyfitbyLineMagnify.pdf (23.2 KB, 2 views)
Reply With Quote
  #8  
Old June 12th, 2014, 12:02 PM
sandig@customprinters.com sandig@customprinters.com is offline
Regular Contributor
 
Join Date: Feb 2010
Posts: 62
Default Re: copyfit by textwidth and then by font size

Dan, do you have any further suggestions from my last post on June 9?
Reply With Quote
  #9  
Old June 12th, 2014, 05:41 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,312
Default Re: copyfit by textwidth and then by font size

Quote:
Originally Posted by sandig@customprinters.com View Post
Dan, do you have any further suggestions from my last post on June 9?
Sorry, I don't. Although you still have not answered this question:
Quote:
Originally Posted by Dan Korn View Post
But what is this "max scaling amount," and where is it specified in the rule?
What is the minimum factor by which you wish to horizontally scale the text before reducing the point size?
__________________
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
  #10  
Old June 13th, 2014, 05:05 AM
sandig@customprinters.com sandig@customprinters.com is offline
Regular Contributor
 
Join Date: Feb 2010
Posts: 62
Default Re: copyfit by textwidth and then by font size

According to the rule, I believe the max scaling amount would be 2100.
i.e.
var thirdnameWidth = CopyfitLineWithMagnifyTag('<f name="Pluto Bold">' +'<z newsize=221>' +thirdname, 2100);
if (TM.textWidth > 210000) // compare as hundredths of points
Reply With Quote
Reply

Tags
copyfit, scaling text

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 02:12 AM.


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