Jump to content

Different Tracking Values for Different Characters in a Field


David Miller

Recommended Posts

Is it possible to set different tracking values for more than one character in a field?

 

Our field "Name" is being formatted ToUpper in another rule and the tracking is set to 20% in the Text Frame Editor.

 

We still had trouble matching the InDesign CS5 layout when fields contained spaces. So, we added the following rule and it solved the problem.

 

return NormalizeEntities(Rule("r_caseselectName")).replace(/ /g, "<tracking newsize=20> </tracking>");

 

Now we must apply a third tracking value to all periods in a field. (For example, John Q. Sample; the tracking for the period must be set to 5.)

 

Unable to find a solution. Thanks.

Link to comment
Share on other sites

I think you just need another replacement:

return NormalizeEntities(Rule("r_caseselectName")).replace(/ /g,  "<tracking newsize=20> </tracking>").replace(/\./g,  "<tracking newsize=5>.</tracking>");

Allthough I don't think you'll be able to match exactly what InDesign is doing. It has its own text layout engine, with its own subtle rules, and there isn't always a "right" way to lay out text. You might want to consider exporting all of your text frames as variable so that FusionPro typesets them; then everything will match.

Link to comment
Share on other sites

Thank you. That worked perfectly.

 

Tried something similar, but was missing the backslash before the period. Is there any reference for the characters used in .replace? (/\./g, ...)

 

Our client was very particular about character spacing and noticed every little difference between the InDesign and FusionPro output. We were able to match everything except fields that contained spaces. (Email Address vs. Job Title) This rule helped. Output was virtually identical to the InDesign file. (Except for some Phone Numbers.)

 

Thanks again for your help.

Link to comment
Share on other sites

Tried something similar, but was missing the backslash before the period. Is there any reference for the characters used in .replace? (/\./g, ...)

Yes, absolutely:

https://developer.mozilla.org/en/JavaScript/Reference/Global_Objects/String/replace

Which leads you to:

https://developer.mozilla.org/en/JavaScript/Reference/Global_Objects/RegExp

 

Although you could accomplish the same thing with FusionPro's ReplaceSubstring function, like so:

var s = NormalizeEntities(Rule("r_caseselectName"));
s = ReplaceSubstring(s, " ", "<tracking newsize=20> </tracking>");
s = ReplaceSubstring(s, ".", "<tracking newsize=5>.</tracking>");
return s;

It's slightly less efficient, and a bit harder to chain together multiple calls, than using String.replace, but it's arguably a bit more straightforward without the regular expressions. Although once you get the hang of using regular expressions, which isn't really that hard with the reference handy, you'll find that they are an extremely powerful tool.

Our client was very particular about character spacing and noticed every little difference between the InDesign and FusionPro output. We were able to match everything except fields that contained spaces. (Email Address vs. Job Title) This rule helped. Output was virtually identical to the InDesign file. (Except for some Phone Numbers.)

Well, the customer is always right. But sometime typesetting can be as much an art as a science.

Link to comment
Share on other sites

Excellent information. Will be very useful.

 

BTW: We were able to match the InDesign CS5 character spacing (tracking) in Phone Numbers by replacing the "space" character (" ") with a " ". Not sure why, but it seems to make a difference (and this is going off-topic for this thread).

 

Many thanks.

Link to comment
Share on other sites

Archived

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

×
×
  • Create New...