Jump to content

Variable tabstop based on TextMeasure value?


MeeshKB

Recommended Posts

I have a tricky business card project wherein I need to add a small seal to the right of certain individuals' name and professional designation. A jpg of the layout is attached for reference.

 

The difficulty I'm having is twofold;

 

1) the graphic needs to be vertically centered to the name and designation line

2) the graphic needs to be positioned a small distance from the end of the name and designation line (which is variable, so the horizontal position of the seal must be too)

 

I had tried including the seal as an inline graphic, but the vertical alignment was an issue. To address that, I followed some good advice given by Dan in another thread and attempted to adjust the baseline of my text to match the graphic by superscripting it. But since my name and designation type sizes are different, and superscript is defined as a percentage of the type size, the baselines of the two didn't match. No good.

 

So my next thought was to put the graphic in its own text box, vertically aligned with the name and designation text, and use a TextMeasure value for the name and designation to either indent or tab it over.

 

I have figured out how to return the tm value, but now am not sure how to use it to define my tabstops or indent.

 

This is the code I've used to measure the name and designation line:

 

 
var name = Field("Name");
var designation = Field("Designation");
var result = "";
var tmName = new FusionProTextMeasure;

tmName.pointSize = "12"; // point size of name
tmName.font = "Myriad Pro Bold"; // font for name
tmName.useTags = true;

var tmDesig = new FusionProTextMeasure;
tmDesig.pointSize = "7"; // point size for designations
tmDesig.font = "Myriad Pro"; // font for designations
tmDesig.useTags = true;

tmName.CalculateTextExtent(name + ", ");
tmDesig.CalculateTextExtent(designation);

return (tmName.textWidth + tmDesig.textWidth);

 

It seems to return the appropriate value. But any ideas on how I can use this value to achieve my goal? Can I reference this rule in my paragraph tags?

 

Am I overthinking this altogether?

EDICardSample.jpg.f00c34c8572aaec9061aa8a2be6a4883.jpg

Link to comment
Share on other sites

Michelle, I think you were on the right track by superscripting the incline graphic. You can adjust the offset percentage and ratio of the superscript with paragraph tags like this:

'<p br=false superoffset=45 superratio=100><superscript><graphic file="name.jpg"></superscript>';

 

After looking at your sample, I think you'd actually probably need to subscript the inline graphic since the baseline is lower than that of the text. The same logic works for subscripting:

'<p br=false suboffset=45 subratio=100><subscript><graphic file="name.jpg"></subscript>';

 

Check out the Tags Reference Guide for more information.

Link to comment
Share on other sites

Thanks, Step.

 

I was in fact superscripting the preceding text, but had trouble because of the differing type sizes.

 

Just tried your suggestion of coding the subscript into a rule to sub the inline graphic. The subscript doesn't seem to affect the graphic at all. This is the same result I got when I applied subscript to it in the text editor yesterday.

 

Here is my code:

 

 
if (Field("Designation").indexOf("G.S.C.") > -1)
{
  return '<p br=false suboffset=45 subratio=100><subscript><graphic file="CCA_Gold_Seal.eps"></subscript>';
}
if (Field("Designation").indexOf("GSC") > -1)
{
  return '<p br=false suboffset=45 subratio=100><subscript><graphic file="CCA_Gold_Seal.eps"></subscript>';
}
return "";

 

A jpg is attached of what I get when I apply subscript to the inline graphic (either through text editor or a rule).

 

It seems that regardless of the subscript settings, the inline graphic can not be adjusted vertically.

 

Any thoughts on how I might apply a tm value to an indent or tabstop to attempt my Plan B?

EDICardSample2.thumb.jpg.b2c44333da7fc83ddb6a687f65b166a2.jpg

Edited by MeeshKB
Link to comment
Share on other sites

Oh sorry I didn't realize that you were superscripting the text. That makes more sense considering (apparently) you can't superscript an inline graphic. Sorry about that suggestion - I didn't test it since I assumed that's what you were doing.

 

I think you could take what you've got and add something like this for the tab stop:

var name = Field("Name");
var designation = Field("Designation");
var result = "";
var tmName = new FusionProTextMeasure;

tmName.pointSize = "12"; // point size of name
tmName.font = "Myriad Pro Bold"; // font for name
tmName.useTags = true;

var tmDesig = new FusionProTextMeasure;
tmDesig.pointSize = "7"; // point size for designations
tmDesig.font = "Myriad Pro"; // font for designations
tmDesig.useTags = true;

tmName.CalculateTextExtent(name + ", ");
tmDesig.CalculateTextExtent(designation);

[color="Red"]var tab = '<p br="false" findent="' + (tmName.textWidth + tmDesig.textWidth) + '">'
var graphic = '<graphic file="CCA_Gold_Seal.eps">';
return = tab + graphic;[/color]

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