Jump to content

OnCopyFit Rule Exceptions


AFitz

Recommended Posts

I've found some threads about handling different situations with OnCopyFit rules (controlling font size, keeping on one line, etc.); however, I'm looking to incorporate a couple of these exceptions into my rule.

 

I have a resizable ad with several variable frames. While my Headline frame can expand to fill up to 36 point size, I don't want the AgentInfo frame (aka Contact Information) to exceed 12 pt. But, I need the actual AgentInfo frame to be large enough to accommodate multiple fields, while some users may only use a few fields. I also want to keep the text that is intended to be on one line, to be on just one line. For example, the company name is the first line (actually typed into the text frame, not pulling from a rule or field), and I want the whole company name to be on one line and not wrap. What do I need to add to the OnCopyFit rule to do this? Below is my current rule:

 

if (!Copyfit(new MagnifyAttributes("text", 25, 200, 8, 36)))

ReportWarning("Could not copyfit text in flow " +

FusionPro.Composition.CurrentFlow.name);

 

Please and thank you!!!

Link to comment
Share on other sites

I actually fixed this by making the base font size of the AgentInfo 12pt (the largest point size I'd except) int the text editor window, and deselected the "Expand to fill" checkbox in the Overflow option. And, for the company name to fit on one line, I created a new CopyfitLine Text rule, from one I found somewhere on this forum. Then inserted this rule in the text frame's text editor with the other fields and rules for that text frame.

 

var lineText = "CompanyName";

var initialFont = "Myriad Pro Cond";

var initialPointSize = 12;

 

if (FusionPro.inValidation)

return lineText;

 

var content = '<f name="' + initialFont + '"><z newsize="' + initialPointSize + '">' + lineText;

var frameWidth = FusionPro.Composition.CurrentFlow.GetFrame().GetSettableTextWidth();

return CopyfitLineWithMagnifyTag(content, frameWidth);

 

function CopyfitLineWithMagnifyTag(line, width, AllowToExpand)

{

var tm = new FusionProTextMeasure;

tm.CalculateTextExtent(line);

if (tm.messages)

ReportError("CopyfitMagnifyLine: " + tm.messages);

 

if (tm.textWidth < width && !AllowToExpand)

return line;

 

var factor = Round(width / tm.textWidth * 100, 0) - 1;

return "<magnify type=text factor=" + factor + ">" + line + "</magnify>";

}

 

If you would have done anything different, please let me know. I could definitely see me needing to manipulate some Copyfit rules in some of my upcoming products.

Link to comment
Share on other sites

It's hard to offer specific suggestions for what sounds like a somewhat complex scenario without seeing the job. That said, a couple general suggestions: First, there is a "Do not break on copyfit" setting in the Paragraph Formatting dialog, which should acconplish "I want the whole company name to be on one line and not wrap." Also, you may be able to break up the content into separate frames, or possibly use a repeatable component, to control how different parts of it are sized. Again, though, it's hard to say without seeing the job.
Link to comment
Share on other sites

Thank you for the response! Yes, it is a complex product and hard to explain without showing, but your explanation made sense to me. :) I thought I had tried the "Do not break on copyfit" in one of my attempts and it didn't work, but now I took out the rule and applied the checkbox to just that text and it worked. Oh well...

 

I was reading it as "Do not break OnCopyFit" like the rule, but I see now it says "Do not break on (space) copyfit" - totally different meaning!

 

I'll come back to this post if I find the scenario where I felt that option wasn't working. Thank you for your time!!

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...