Go Back   PTI Marketing Technologies User Community > Software-Related Talk > The JavaScript Library > Formatting Text

Notices

Reply
 
Thread Tools Search this Thread Display Modes
  #11  
Old July 14th, 2017, 10:56 AM
step's Avatar
step step is offline
Senior Contributor
 
Join Date: Jan 2010
Location: Charlotte, NC
Posts: 921
Default Re: Default Font Size to remain at Min if Copyfit does not fit.

Quote:
Originally Posted by jl_arnold View Post
I know where I need to modify my coding to get this to function how I need to, but I just don't know how to, or if it's possible.
Right, well that's why I suggested contracting a developer to help.

Quote:
Originally Posted by jl_arnold View Post
Basically I have two separate replace functions going on in my Copyfit rule. I need them to work simultaneously, but they seem to work one, then the other.
Technically there are 3 replace methods but I'm going to assume you're referring to the one that replaces the 'verticalstart" attribute and the one that replaces the leading with the "leadingSizeBody." What do you mean you need them to work simultaneously? You can chain replace methods if that's what you're wanting to do (although I don't know why):
Code:
return '<p br="false" quad="L">First paragraph.'
     + '<p verticalstart="topofpage" quad="L">Second paragraph'
       .replace('verticalstart="topofpage"', '') 
       .replace(/(quad="[A-Z]" )(leading="\d+")?/g, function(s,p) {
          return p + 'leading="' + leadingSizeBody * 10 + '"';
        }); 
/*
  Returns:
  <p br="false" quad="L" leading="140">First paragraph.
  <p quad="L" leading="140">Second paragraph
*/
I think part of the reason for the confusion is stemming from syntax errors. Let's take a closer look at your code:
Code:
var minSize = 9;
var leadingSizeBody = 14

if (FusionPro.Composition.CurrentFlow.name == "MainArticleBodyCopy1-3")
{
var cf = FusionPro.Composition.CurrentFlow;
// If it doesn't fit, don't start back page at "topofpage"
if (!cf.fits)
    cf.content = cf.content.replace(/<variable name="([^"]+)">/g, function(s,p) {
        return RuleOrField(p).replace('verticalstart="topofpage"', 'leadbefore="0"');
   });
            if (!Copyfit(new MagnifyAttributes("text", 80, 150, minSize, 10),new MagnifyAttributes("leading", 80, 150, leadingSizeBody, 15)))
                   cf.content = '<para><span pointsize="' + minSize +'">'
    + cf.content.replace(/(quad="[A-Z]" )(leading="\d+")?/g, function(s,p) { return p + 'leading="' + leadingSizeBody * 10 + '"'; })
    + '</span></para>';    
    ReportWarning("Could not copyfit text in flow " + 
                  FusionPro.Composition.CurrentFlow.name);
}
Everything within the red brackets executes if and only if the name of the text flow is "MainArticleBodyCopy1-3." The pink code checks to see if the content fits in the text flow (before attempting to copyfit) and if it doesn't, it replaces the first "verticalstart" attribute with "leadbefore=0." The green code (my apologies if you are red/green colorblind) attempts to copyfit the text flow by adjusting the font size and leading within the limitations you defined and if it can not, it wraps the entire content in span tags (to set the font size to the minimum) and applies the minimum leading to all 'p' tags. The "ReportWarning" part actually executes every time the "MainArticleBodyCopy1-3" text flow is processed. That's resulting in a false error so you might want to only do that if the copyfit fails – in which case you need to wrap that 'if' statement in brackets (because you're executing multiple lines of code):
Code:
if (!Copyfit(new MagnifyAttributes("text", 80, 150, minSize, 10), new MagnifyAttributes("leading", 80, 150, leadingSizeBody, 15))) {
  cf.content = '<para><span pointsize="' + minSize +'">' + cf.content.replace(/(quad="[A-Z]" )(leading="\d+")?/g, function(s,p) { return p + 'leading="' + leadingSizeBody * 10 + '"'; }) + '</span></para>';    
  ReportWarning("Could not copyfit text in flow " + FusionPro.Composition.CurrentFlow.name);
}
__________________
Ste Pennell
FusionPro VDP Creator 9.3.15
Adobe Acrobat X 10.1.1
Mac OS X 10.12

LinkedIn
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 06:42 PM.


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