MarcomCentral (PTI) and FusionPro User Communities

MarcomCentral (PTI) and FusionPro User Communities (http://forums.pti.com/index.php)
-   FusionPro® VDP Creator (http://forums.pti.com/forumdisplay.php?f=5)
-   -   Possible to use CopyfitLine with "Do not break on copyfit"? (http://forums.pti.com/showthread.php?t=5055)

lkain December 18th, 2017 07:02 PM

Possible to use CopyfitLine with "Do not break on copyfit"?
 
Hi all,

As the title indicates, I'm wondering if it's possible to modify the CopyfitLine code in such a way that the line will not break to multiple lines before trying to copyfit.

I currently have the javascript below:

Code:

return CopyfitLine("", Field("contactName"), "Helvetica Neue", 9.5, 105.35, 7, false);
However, because I have plenty of room in my text box for the line to break, and because there's a space in the field value ("Firstname Lastname"), it's breaking at the space before it attempts to copyfit. I have "Do Not Break On Copyfit" selected in my text box, but I am guessing that only works on the normal OnCopyfit rule, and not on CopyfitLine.

Is there a javascript function (or other solution) I can use to ensure the line does not break at the space? I should mention, using a non-breaking space isn't a great solution for us, as more often than not, FusionPro will spit out boxes with Xs in them in composition whenever a non-breaking space is used (but that's a different issue altogether).

Any help is appreciated!

lkain December 18th, 2017 07:15 PM

Re: Possible to use CopyfitLine with "Do not break on copyfit"?
 
As a quick follow-up... out of curiosity, I removed the space in the field value, and while the copyfit did occur, it is still breaking to two lines, even though it could copyfit to a lower point size.

The javascript validates to the below:
Code:

<f name="Helvetica Neue"><z newsize=9.5><z newsize=7.800000000000006>EdwardHanrahanhfewfwerewr
However, I have in my rule to allow it to copyfit down to 6.5pt. I can't figure out why it stops at 7.8pt and continues to want to break.

As an aside, I have the same rule being applied to another field (email address) in the same text box, and the email address version works flawlessly. Is it possible the two rules are conflicting with one another?

Thanks.

step December 18th, 2017 09:03 PM

Re: Possible to use CopyfitLine with "Do not break on copyfit"?
 
It seems a little excessive, but you could use FusionProTextMeasure:
Code:

var contactName = 'Edward Hanrahanhfewfwerewr';
var pointSize = { max: 9.5, min: 6.5 };
contactName = '<span font="Helvetica Neue" pointsize="' + pointSize.max + '">' + contactName + '</span>';
var limit = Int((pointSize.min / pointSize.max) * 100);
return NoBreakCopyfit(contactName, 100, limit);

function NoBreakCopyfit(str, mag, min) {
  if (FusionPro.inValidation) return str;
  try {
    var frameName = FusionPro.Composition.CurrentFlow.name;
    var width = GetSettableTextWidth(FindTextFrame(frameName));
  } catch(e) {
    ReportError('Must name text frame and set rule to "Re-evaluate this rule for every text flow"');
  }
  var tm = new FusionProTextMeasure;
  tm.useTags = true;
  tm.maxWidth = width;
  var magnified = '<magnify factor="' + mag + '" type="text">' + str + '</magnify>';
  tm.CalculateTextExtent(magnified);
  return tm.textLines > 1 && mag > min ? NoBreakCopyfit(str, --mag, min) : magnified;
}

Make sure you name your text frame and set the rule to "Re-evaluate this rule for every text flow."


All times are GMT -7. The time now is 02:42 PM.

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