Jump to content

Right Justified text, and left line alignment


EvanF

Recommended Posts

I have a right justified Email, and I need to align the Cellphone line to the left most extents of the Email line.

 

I have a formatting issue I've been trying to tackle, however the FusionProTextMeasure seems to be limited by a defined point size, so when copyfit takes over the measurement is no longer accurate. I'm not sure if this is even the best way to approach this as I'm quite new to FusionPro.

 

This approach calculates the size of both lines, subtracts them to get the difference and tosses that into a rindent tag format for the cellphone line.

 

var rightIndentSize = function () {
   // Default Pt Size
   var ptSize = "6 pt";

   // Email Size
   var emailString = "email: " + Rule("Email_Format");
   var emailTM = new FusionProTextMeasure;
   emailTM.pointSize = ptSize;
   emailTM.font = "Helvetica";
   emailTM.useTags = false;
   emailTM.CalculateTextExtent(emailString);

   // Cellphone Size
   var cellString = "cell: " + Rule("Cellphone_Format");
   var cellTM = new FusionProTextMeasure;
   cellTM.pointSize = ptSize;
   cellTM.font = "Helvetica";
   cellTM.useTags = false;
   cellTM.CalculateTextExtent(cellString);

   // Calculate difference in size
   var tmWidth = (emailTM.textWidth - cellTM.textWidth);
   return tmWidth;
}

return "<p rindent=" + rightIndentSize() + ">" + "cell: " + Rule("Cellphone_Format") + "</p>";

 

I'd like to have this work with copyfit as some of the emails are bound to get quite long. Also it would be nice if the rules weren't hard coded for font sizes, might make the rules a little more versatile.

 

Any help is much appreciated.

 

Thanks,

Evan

Archive.zip

Link to comment
Share on other sites

I think it has to do with using the right indent. If you left justify your text box, remove the email rule from it, you can simplify things a bit by modifying your "Test_testbox" rule to look like this:

var frameWidth = 1.89 * 7200; // 1.89 inches


var email = "email: " + ToLower(Field("Email"));
var cell = "cell: " + Rule("Cellphone_Format");

// Email Size
   var emailTM = new FusionProTextMeasure;
   emailTM.pointSize = "6 pt";
   emailTM.font = "Helvetica";
   emailTM.useTags = false;
   emailTM.italic = true;
   emailTM.CalculateTextExtent(email);
   var indent = frameWidth-emailTM.textWidth;

return "<p findent=" + indent + ">" + cell + "</p><br><p findent=" + indent + ">" + email + "</p>";

It's essentially indenting the email address to be right aligned and indents the cellphone number the same amount (from the left). Copyfit works with those modifications.

Link to comment
Share on other sites

You can do this without writing a rule at all. One way is to just type whatever you need into the Text Editor, and put a tab in between the two parts. Then click the Tabs button, and in the Edit Tab Stops dialog, add a right-aligned tab stop, with the position just a bit less than the width of the frame. Edited by Dan Korn
typo
Link to comment
Share on other sites

Also, just a comment on this:

however the FusionProTextMeasure seems to be limited by a defined point size

That's true only if you have the useTags property of the FusionProTextMeasure object set to false. If you set it to true, then you can use multiple <z newsize=***> and other formatting tags in the text, which can have as many "runs" of text with different point sizes and other attributes as you want, and it will measure the entire thing.

Link to comment
Share on other sites

You can do this without writing a rule at all. One way is to just type whatever you need into the Text Editor, and put a tab in between the two parts. Then click the Tabs button, and in the Edit Tab Stops dialog, add a right-aligned tab stop, with the position just a bit less than the width of the frame.

 

Can you provide a sample of this as it doesn't seem to work as you describe. As the solution Step provided isn't quite working as intended.

Link to comment
Share on other sites

  • 11 months later...

Thanks for giving the example using tabs and right align.

Solved a problem I was having with a variable menu board. When ever a price was over 9.99 it was pushing the numbers out of alignment. Using tab and right align made it all line up nicely.

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