Go Back   MarcomCentral (PTI) and FusionPro User Communities > Software-Related Talk > The JavaScript Library > Formatting Text

Notices

Reply
 
Thread Tools Search this Thread Display Modes
  #1  
Old October 11th, 2010, 09:39 AM
mstanton mstanton is offline
Regular Contributor
 
Join Date: Aug 2009
Posts: 65
Question Help! Need to format numbers in a string of text

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
__________________
-Megan

I am Using: EFI Digital Storefront v7.0.0.20391 / FusionPro Designer 9.2.25 / Mac OS 10.6.8 / Acrobat 10.1.9 and Acrobat 11.0.06 / InDesign CC v9.2 and InDesign CS5.5 v7.5.3
Reply With Quote
  #2  
Old October 11th, 2010, 01:25 PM
rpaterick rpaterick is offline
Senior Contributor
 
Join Date: Mar 2009
Posts: 427
Default Re: Help! Need to format numbers in a string of text

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.
__________________
Windows 7 64BIT
Intel - I7 chip - 3.33Ghz - 6GB ram
8.0 Creator/8.0 Producer/CS5.5
Reply With Quote
  #3  
Old October 11th, 2010, 01:39 PM
mstanton mstanton is offline
Regular Contributor
 
Join Date: Aug 2009
Posts: 65
Default Re: Help! Need to format numbers in a string of text

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

I am Using: EFI Digital Storefront v7.0.0.20391 / FusionPro Designer 9.2.25 / Mac OS 10.6.8 / Acrobat 10.1.9 and Acrobat 11.0.06 / InDesign CC v9.2 and InDesign CS5.5 v7.5.3
Reply With Quote
  #4  
Old October 11th, 2010, 04:55 PM
Dan Korn's Avatar
Dan Korn Dan Korn is offline
FusionPro Senior Engineer / Forum Moderator
 
Join Date: Aug 2008
Location: Chicago, IL
Posts: 4,322
Default Re: Help! Need to format numbers in a string of text

Try this in a Text JavaScript rule:
Code:
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.
__________________
Dan Korn
FusionPro Developer / JavaScript Guru / Forum Moderator
PTI Marketing Technologies | Printable | MarcomCentral
LinkedIn

I am a not a Support engineer, and this forum is not a substitute for Support. My participation on this forum is primarily as a fellow user (and a forum moderator). I am happy to provide help and answers to questions when I can; however, there is no guarantee that I, or anyone else on this forum, will be able to answer all questions or fix any problems. If I ask for files to clarify an issue, I might not be able to look at them personally. I am not able to answer private messages, emails, or phone calls unless they go through proper Support channels. Please direct any sales or pricing questions to your salesperson or inquiries@marcom.com.

Complex template-building questions, as well as all installation and font questions or problems, should be directed to FusionProSupport@marcom.com. Paid consulting work may be required to fulfill your template-building needs.

This is a publicly viewable forum. Please DO NOT post fonts, or other proprietary content, to this forum. Also, please DO NOT post any "live" data with real names, addresses, or any other personal, private, or confidential data.

Please include the specific versions of FusionPro, Acrobat, and your operating system in any problem reports or help requests. I recommend putting this information in your forum signature. Please also check your composition log (.msg) file for relevant error or warning messages.

Please post questions specific to the MarcomCentral Enterprise and Web-to-Print applications in the MarcomCentral forum. Click here to request access. Or contact your Business Relationship Manager (BRM/CPM) for assistance.

Please direct any questions specific to EFI's Digital StoreFront (DSF) to EFI support.

How To Ask Questions The Smart Way

The correct spellings are JavaScript, FusionPro, and MarcomCentral (each with two capital letters and no spaces). Acceptable abbreviations are JS, FP, and MC (or MCC). There is no "S" at the end of "Expression" or "Printable"! The name of the product is FusionPro, not "Fusion". "Java" is not is not the same as JavaScript.

Check out the JavaScript Guide and JavaScript Reference! FusionPro 8.0 and newer use JavaScript 1.7. Older versions use JavaScript 1.5.

return "KbwbTdsjqu!spdlt\"".replace(/./g,function(w){return String.fromCharCode(w.charCodeAt()-1)});
Reply With Quote
  #5  
Old October 12th, 2010, 09:35 AM
mstanton mstanton is offline
Regular Contributor
 
Join Date: Aug 2009
Posts: 65
Default Re: Help! Need to format numbers in a string of text

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!
__________________
-Megan

I am Using: EFI Digital Storefront v7.0.0.20391 / FusionPro Designer 9.2.25 / Mac OS 10.6.8 / Acrobat 10.1.9 and Acrobat 11.0.06 / InDesign CC v9.2 and InDesign CS5.5 v7.5.3
Reply With Quote
  #6  
Old October 12th, 2010, 10:31 AM
Dan Korn's Avatar
Dan Korn Dan Korn is offline
FusionPro Senior Engineer / Forum Moderator
 
Join Date: Aug 2008
Location: Chicago, IL
Posts: 4,322
Default Re: Help! Need to format numbers in a string of text

Quote:
Originally Posted by mstanton View Post
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.
Quote:
Originally Posted by mstanton View Post
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:
Code:
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>';});
__________________
Dan Korn
FusionPro Developer / JavaScript Guru / Forum Moderator
PTI Marketing Technologies | Printable | MarcomCentral
LinkedIn

I am a not a Support engineer, and this forum is not a substitute for Support. My participation on this forum is primarily as a fellow user (and a forum moderator). I am happy to provide help and answers to questions when I can; however, there is no guarantee that I, or anyone else on this forum, will be able to answer all questions or fix any problems. If I ask for files to clarify an issue, I might not be able to look at them personally. I am not able to answer private messages, emails, or phone calls unless they go through proper Support channels. Please direct any sales or pricing questions to your salesperson or inquiries@marcom.com.

Complex template-building questions, as well as all installation and font questions or problems, should be directed to FusionProSupport@marcom.com. Paid consulting work may be required to fulfill your template-building needs.

This is a publicly viewable forum. Please DO NOT post fonts, or other proprietary content, to this forum. Also, please DO NOT post any "live" data with real names, addresses, or any other personal, private, or confidential data.

Please include the specific versions of FusionPro, Acrobat, and your operating system in any problem reports or help requests. I recommend putting this information in your forum signature. Please also check your composition log (.msg) file for relevant error or warning messages.

Please post questions specific to the MarcomCentral Enterprise and Web-to-Print applications in the MarcomCentral forum. Click here to request access. Or contact your Business Relationship Manager (BRM/CPM) for assistance.

Please direct any questions specific to EFI's Digital StoreFront (DSF) to EFI support.

How To Ask Questions The Smart Way

The correct spellings are JavaScript, FusionPro, and MarcomCentral (each with two capital letters and no spaces). Acceptable abbreviations are JS, FP, and MC (or MCC). There is no "S" at the end of "Expression" or "Printable"! The name of the product is FusionPro, not "Fusion". "Java" is not is not the same as JavaScript.

Check out the JavaScript Guide and JavaScript Reference! FusionPro 8.0 and newer use JavaScript 1.7. Older versions use JavaScript 1.5.

return "KbwbTdsjqu!spdlt\"".replace(/./g,function(w){return String.fromCharCode(w.charCodeAt()-1)});
Reply With Quote
  #7  
Old October 12th, 2010, 10:49 AM
mstanton mstanton is offline
Regular Contributor
 
Join Date: Aug 2009
Posts: 65
Default Re: Help! Need to format numbers in a string of text

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:
Code:
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>';});
__________________
-Megan

I am Using: EFI Digital Storefront v7.0.0.20391 / FusionPro Designer 9.2.25 / Mac OS 10.6.8 / Acrobat 10.1.9 and Acrobat 11.0.06 / InDesign CC v9.2 and InDesign CS5.5 v7.5.3

Last edited by mstanton; October 12th, 2010 at 10:56 AM..
Reply With Quote
  #8  
Old October 13th, 2010, 05:28 AM
esmith's Avatar
esmith esmith is offline
Senior Contributor
 
Join Date: Oct 2008
Location: Charlotte, NC
Posts: 870
Default Re: Help! Need to format numbers in a string of text

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:
Code:
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>';});
__________________
Eric Smith
Content Developer
Classic
FP 9.3.6, MAC OSX 10.9.4, Acrobat 11.0.09
Reply With Quote
Reply

Tags
fonts, number formatting, numbers, opentype

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT -7. The time now is 10:17 PM.


Powered by vBulletin® Version 3.8.4
Copyright ©2000 - 2019, Jelsoft Enterprises Ltd.
(c) 2011, PTI Marketing Technologies™, Inc.