Jump to content

Sizing Inline Graphic with Variable font

Paul Cos

Recommended Posts

I am looking to insert an “inline graphic” in front of a variable text field that would resize with the height of the text.

Right now, I have a copyfitline rule that will resize the text based on the width of the box but the graphic doesn’t get smaller when the text does.

I tried a regular CopyFit but it doesn’t resize the graphic either. The graphic is as big as the largest font size.

Is there a way to measure the height of the text as it appears and apply it to the <graphic> tag?


This is what I have so far. A RULE called CustomBrandingArea with this tag return '<graphic file="CustomBrandingArea.jpg">'


I created a (field) called logo and place a logo as a Resources and called it logo2 and another RULE called TEST_RULE with this tag if (Field("logo2") != "") return '<magnify type=textwidth factor=100><z newsize=12.06>'+ Field("City") +Rule("CustomBrandingArea") + '</magnify>' ; else return ""

Link to comment
Share on other sites

A picture of what you're trying to accomplish would be worth a thousand words, and the collected job with the data would be better, so I have to do some guessing based on the limited information provided. But you should be able to use a variation of the CopyfitLineWithMagnifyTag function.


Something like this should work, though I haven't tested it:

var factor = 100;
function CopyfitLineWithMagnifyTag(line, widthInPoints, AllowToExpand)
   var tm = new FusionProTextMeasure;
   if (tm.messages)
     ReportError("CopyfitMagnifyLine: " + tm.messages);

   if (tm.textWidth < widthInPoints*100 && !AllowToExpand)
     return line;

   factor = Round(widthInPoints / tm.textWidth * 10000, 0) - 1;
   return "<magnify type=pointsize factor=" + factor + ">" +
           line + "</magnify>";

var frameWidth = 3 * 7200; // for rule validation, 3 inches
var frame = FusionPro.Composition.CurrentFlow.GetFrame();
if (frame.GetSettableTextWidth)
   frameWidth = frame.GetSettableTextWidth();

// Put your font and initial size here:
var font = "Arial";
var pointSize = 12;
var text = '<graphic file="CustomBrandingArea.jpg" height=' + (pointSize * 100) +
               '><f name="' + font + '"><z newsize=' + pointSize + '>' + TaggedDataField("City");

var result = CopyfitLineWithMagnifyTag(text, frameWidth, true);
return ReplaceSubstring(result, 'height=' + (pointSize * 100),
               'height=' + (pointSize * factor));

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.

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...