Jump to content

Font size changing


Recommended Posts

Hi, maybe I'm over thinking this but hopefully someone can help me. I have 4 lines that are set to fit to a 2.25" x 1.25" text frame. I have it set to fit to the frame with 4 similar rules as per the name of the field. If the "name" is only 10 characters long but the "title" is 25 - 30 every field shrinks to the longest field. What I would like is for each field to fit based on it's own attributes. Basically, if I have the text set in the frame to 20 pt I prefer that only the longer information scales down and the 20 pt remains on anything that would fit at that point size. Hope this makes sense. I've attached my file to give a better idea. Thank you!

Black Marble Pen Holder 2.5 x 4.5.zip

Link to comment
Share on other sites

You were very close. Each rule can just call CopyfitLineWithMagnifyTag to fit itself independently.

 

I tweaked the code just a bit, putting this into the JavaScript Globals:

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) - 10;
   return "<magnify type=text factor=" + factor + ">" + line + "</magnify>";
}

function FitInfoLine(fieldName)
{
   var lineText = TaggedDataField(fieldName);

   var font = Field("Font");
   switch (font)
   {
     case "Gotham":
       font = "Gotham Medium";
         break;
     case "Goudy":
       font = "GoudyOldStyExtBol";
         break;
   }

   //font = "Arial"; // I used this since I don't have your fonts.
   var pointSize = 14;

   var content = '<f name="' + font + '"><z newsize="' + pointSize + '">' + lineText;
   var frameWidth = FindTextFrame(FusionPro.Composition.CurrentFlow.name || "info").GetSettableTextWidth();
   return CopyfitLineWithMagnifyTag(content, frameWidth);    
}

Then each of the four rules become one-liners, like so:

return FitInfoLine("Name");

return FitInfoLine("Title");

return FitInfoLine("Department");

return FitInfoLine("SC");

Finally, and this is very important, you need to turn OFF copyfitting for the frame, in the Overflow Options dialog.

Edited by Dan Korn
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...