Here's a version that allows the text to optionally expand, as well as
shrink, to fit a particular space:
function CopyfitToLines(text, widthInPoints, numLines,
allowToExpand, magnifyType)
{
var MagnifyType = magnifyType || "text";
var NumLines = Int(numLines) || 1;
var tm = new FusionProTextMeasure;
tm.maxWidth = widthInPoints*100;
var tags = text;
var factor = 100
var lastTags = tags;
var fitsInitially = false;
while (factor >= 10 && factor < 10000)
{
lastTags = tags;
if (factor != 100)
tags = "<magnify type=" + MagnifyType +
" factor=" + factor + ">" +
text + "</magnify>";
var retcode = tm.CalculateTextExtent(tags);
if (tm.messages)
ReportError("CopyfitToLines: " + tm.messages);
if (retcode != 0)
break;
if (factor == 100 && tm.textLines <= NumLines)
fitsInitially = true;
if (fitsInitially && allowToExpand)
{
if (tm.textLines > NumLines)
return lastTags;
factor++;
}
else
{
if (tm.textLines <= NumLines)
return tags;
factor--;
}
}
ReportWarning("CopyfitToLines failed to fit the text");
return text;
}
Happy copyfitting!
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
--