View Single Post
  #3  
Old December 18th, 2017, 08:03 PM
step's Avatar
step step is offline
Senior Contributor
 
Join Date: Jan 2010
Location: Charlotte, NC
Posts: 955
Default 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."
__________________
Ste Pennell
FusionPro VDP Creator 9.3.15
Adobe Acrobat X 10.1.1
Mac OS X 10.12

LinkedIn
Reply With Quote