Jump to content

Centering left-aligned bullets?


esmith

Recommended Posts

I just received a project with static mock-ups that show all text (which will be variable) centered on a page. However, the text includes 1-3 lines of "bulleted" copy where the bullets are left aligned with each other so that the longest of the three still appears centered below the rest of the text. Of course, from record to record, the data for the bullets will be of varying widths so the "left margin" will need to move based on the width of the longest line.

 

Is there a way to handle this using one of the text measure features? I'm guessing there's some way to pull this off, but that there are likely certain scenarios (like having one bullet wrap to two lines?) that would break it in which case I'd want to tell the customer up front that we need to modify the design.

Link to comment
Share on other sites

Eric, I pulled this from one of your previous post and made a few tweaks to it. Give it a try and see what you think:

 

 // CHANGE THIS TO THE WIDTH OF YOUR FRAME
   var FrameWidth = 11 * 7200;

   // CHANGE THIS TO WHATEVER LINES YOU HAVE
   var Lines = [  Field("1"), Field("2"), Field("3"), Field("4") ];

   var tm = new FusionProTextMeasure;

   // CHANGE THESE TO MATCH YOUR TEXT ATTRIBUTES
   tm.pointSize = "12 pt";
   tm.font = "Helvetica";
   tm.bold = true;
   tm.useTags = true;

   var LargestWidth = 0;

   for (var i = 0; i < Lines.length; i++)
   {
     if (tm.CalculateTextExtent(Lines[i]))
       return "***ERROR***: " + tm.messages;
     var LineWidth = tm.textWidth;
     if (LineWidth > LargestWidth)
       LargestWidth = LineWidth;
   }

   var LineIndent = (FrameWidth - LargestWidth)/2;


   var result = "";

   for (var i = 0; i < Lines.length; i++)
   {
     result += "<p findent=" + LineIndent + ">";
     result += NormalizeEntities(Lines[i]);
   }

   return result;

Link to comment
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...