Here's a function I wrote to basically do what CopyfitLine does, using
the <magnify> tag and a more efficient algorithm:

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

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

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

(Sorry again for any wrapping in the email.)

The idea here is that we don't need to iterate until we find a size that
fits; we can simply take the ratio of how big the line is already
compared to the desired width and use that as the magnification factor.

Note that you have to specify all the font and size information with
tags.  So a call would look something like this:

  return CopyfitLineWithMagnifyTag('<f name="Arial">' +
            '<z newsize=12>' + Field("Address"), 360);

The caller can add the optional third parameter of "true" to allow the
text to get bigger, like so:

  return CopyfitLineWithMagnifyTag('<f name="Arial">' +
            '<z newsize=12>' + Field("Address"), 360, true);

This function could also be modified to take parameters specifying the
font name and bold/italic faces.

Dan


+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-
Calling all FP Web Users!

Do you have a question or lots of knowledge to share about FusionPro Web?

If so, join our Printable Web to Print Users' Forum today!

Send email to [EMAIL PROTECTED] to find out how!
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-


--
Users of FusionPro Desktop have unlimited free email support. Contact Printable 
Support at [EMAIL PROTECTED]
--
View FusionPro Knowledge Base, FusionPro Samples at
www.printable.com/vdp/desktop.htm

--
You are currently subscribed to fusionpro as: [EMAIL PROTECTED]
To unsubscribe send a blank email to [EMAIL PROTECTED]
--


--
Note:  All e-mail sent to or from this address will be received or otherwise 
recorded by the e-mail recipients of this forum. It is subject to archival, 
monitoring or review by, and/or disclosure to someone other than the recipient. 
Our privacy policy is posted on www.printplanet.com
--

Reply via email to