Hello,
I have several variables in the same text frame and I don't want the text to wrap to another line if it doesn't fit. I also don't want to use copyfitting as I don't want the point size to change. The text needs to be truncated if too long.
Variables in text frame:
<FirstName><MiddleName><Last Name>
<Title>
Data File Values:
FirstName: Samantha
MiddleName: M.
LastName: Smithwicks-Jefferson
Title: Administrator; Broker; Realtor; Office; Manager; Owner; President
I have tried the text measurement code from another posted thread and it did work when I wrote the rule for the <Title> line field - but does not work correctly for the NAME line fields which are nested in the same rule - see blue in code below:
__________________________________________________
function TruncateText(text, font, pointSize, width) // width and pointSize in hundredths of points
{
var TM = new FusionProTextMeasure;
TM.useTags = false;
TM.maxWidth = width;
TM.font = font;
TM.pointSize = pointSize;
for (var partial = text; partial; partial = partial.substr(0, partial.length - 1))
{
TM.CalculateTextExtent(partial);
if (TM.textLines <= 1)
return partial;
}
throw "Nothing fits";
}
return TruncateText('<uppercase>' + (NormalizeEntities(Field("FirstName")) + " " +
(Field("MiddleName")) + " " + (Field("LastName")) + '</uppercase>'), "Aller Bold", 1000, FindTextFrame("Untitled1").GetSettableTextWidth());
__________________________________________________
Here is the result when I compose:
SAMANTHA M. SMITH
Administrator; Broker; Realtor; Offi
The name line is breaking too short - it should be truncating the same width (approx.) as the title line above. It does seem to break correctly when I remove <uppercase>, but I need the name in all caps. Also, depending on where I placed <uppercase> I was getting different results in where the names broke.
Any assistance would be appreciated. My apologies for the length of this message!