Jump to content

Help! Need to format numbers in a string of text


mstanton

Recommended Posts

Hello,

 

Since FusionPro does not support OpenType features (see my post here: http://forums.printable.com/showthread.php?t=1697) I need to do some work-arounds to get numbers in an address line to stay within the baseline and cap height.

 

The only way I can think to do this is to use a different font for the numbers. This is easy for things like the ZIP code where it has its own field, but how do I do this in an address line where the numbers are inline with other text and can show up anywhere?

 

Thanks!

-Megan

Link to comment
Share on other sites

http://www.fontlab.com/font-converter/transtype/

 

 

You should be able to get Adobe PostSript, OTF, and TT MAC font from this program. I would download the demo version, see if it works converting the OTF font into the either the .ps font or .tt font and then try it again. Downloading the demo program and see, might be worth it.

 

The program has paid for itself for us considering we have a Mac to PC workflow sometimes and I have to convert the Mac font to PC.

 

The demo program might put little WATERMARKS on the font to show you a little taste. The WATERMARKS should go away once you purchase the PRO version.

 

$179.00, you can't beat it.

Link to comment
Share on other sites

Thanks for the suggestion, but it's not that FusionPro can't handle OpenType fonts, it's that it can't handle options that can be turned on and off within the OpenType font in InDesign. In the normal font the numbers do not fit between the cap height and the baseline. However, turning on the OpenType feature of Proportional Lining makes the numbers fit within this space. So it's not the original font itself, it's the feature of Proportional Lining that FusionPro doesn't support. Converting the font to TrueType or anything else will not fix this as far as I can tell.

 

I still need to know how to tell FP to change any number to be a different font, but to leave the rest of the string alone.

Link to comment
Share on other sites

Try this in a Text JavaScript rule:

var numberFont = "Arial";
var text = NormalizeEntities(Field("Add1"));
return text.replace(/(\d+\s*)/g, function(d){return '<f name="' + numberFont + '">' + d + '</f>';});

Be sure to replace the font and field names on the first two lines, and check the "Treat returned strings as tagged text" box.

 

You'll need to make a rule like this for each field in which you want this effect. You can name each rule with the same name as the corresponding field and any references to those fields in text frames will automatically pick up the rules instead.

Link to comment
Share on other sites

Wonderful! That works splendidly. My next question is, is there a way to change the horizontal scale, vertical scale, and tracking of the font as well?

 

Also, is there a way to combine this with the Change phone format rule?

 

Thanks!

Link to comment
Share on other sites

Wonderful! That works splendidly. My next question is, is there a way to change the horizontal scale, vertical scale, and tracking of the font as well?

Yes, there are markup tags for all of those text attributes and more. Please refer to the FusionPro Tags Reference Guide.

Also, is there a way to combine this with the Change phone format rule?

Sure, the easiest way is probably just to call one rule from the other, like so:

var numberFont = "Arial";
var text = NormalizeEntities(Rule("Change phone format Rule"));
return text.replace(/(\d+\s*)/g, function(d){return '<f name="' + numberFont + '">' + d + '</f>';});

Link to comment
Share on other sites

Thanks

 

I am trying to use the setwidth tag, as mentioned in the Tags reference guide, but it is changing the width of the entire paragraph, not just the numbers. I am not great with javascript and have no training for it; I am learning as I go so I apologize for being a bit slow with it.

 

This is what I have:

var numberFont = "Folio Light";
var numberWidth = "4";
var text = NormalizeEntities(Field("ADDRESS1"));

return text.replace(/(\d+\s*)/g, function(d){return '<f name="' + numberFont + '"><setwidth newsize="' + numberWidth + '">' + d + '</f>';});

Link to comment
Share on other sites

I think this is a perfect scenario for why Dan was touting the <span> tag in another recent thread. The <setwidth> tag has no closing tag associated with it so you wind up affecting all trailing text in your frame if you don't explicitly "undo" the change. The <span> tag compartmentalizes your tags and "resets" your settings back to what they were before the tag was defined. To implement in your existing code, try changing as follows:

var numberFont = "Folio Light";
var numberWidth = "4";
var text = NormalizeEntities(Field("ADDRESS1"));

return text.replace(/(\d+\s*)/g, function(d){return '<span font="' + numberFont + '"><setwidth newsize="' + numberWidth + '">' + d + '</span>';});

Link to comment
Share on other sites

Archived

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

×
×
  • Create New...