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 May 23rd, 2014, 10:04 AM
inxcapable inxcapable is offline
Forum n00b
 
Join Date: Aug 2012
Location: Seattle
Posts: 3
Default Using Multiple Fonts in a single field

We are building a business card for a client. It's pretty straightforward except for the fact that we need to use two different fonts to create the card - one for numbers and one for text. In order to control the fonts we need to use JavaScript rules. The fields that are impacted are the street address and email address fields.

Text = MrEavesSanOT
Numbers = MrEavesModOT

PTI supplied this Javascript rule for us to use:

newAddress = '<f name="MrEavesSanOT">' + Field("Address").replace(/(\d+)/g, '<f name="MrEavesModOT">$1</f>'); return newAddress;

It sort of works, but it causes a situation where if a house number is followed by a street number, the numbers concatenate. 777 77th Avenue reads as 77777th Avenue.

They told us to remove </f> after MrEavesModOT. It corrects the concatenation issue. But then causes any text that appears after a number to render as MrEavesModOT. We need text to be rendered as MrEavesSanOT.

I’d appreciate your feedback. Thanks!
Reply With Quote
  #2  
Old July 1st, 2014, 11:35 AM
inxcapable inxcapable is offline
Forum n00b
 
Join Date: Aug 2012
Location: Seattle
Posts: 3
Default Re: Using Multiple Fonts in a single field

Does anyone have insight to this issue? We're still unresolved and I need to launch this site in the next couple of week.
Reply With Quote
  #3  
Old July 1st, 2014, 11:48 AM
step's Avatar
step step is offline
Senior Contributor
 
Join Date: Jan 2010
Location: Charlotte, NC
Posts: 955
Default Re: Using Multiple Fonts in a single field

Would this work?
Code:
newAddress = '<f name="MrEavesSanOT">' + Field("Address").replace(/(\d+)/g, '<f name="MrEavesModOT">$1<f name="MrEavesSanOT">'); return newAddress;
__________________
Ste Pennell
FusionPro VDP Creator 9.3.15
Adobe Acrobat X 10.1.1
Mac OS X 10.12

LinkedIn
Reply With Quote
  #4  
Old July 1st, 2014, 12:24 PM
dreimer dreimer is offline
Senior Contributor
 
Join Date: Oct 2010
Location: Shakopee, MN
Posts: 473
Default Re: Using Multiple Fonts in a single field

I used this in the past. May work.

Code:
function replace_helper(match, digits, spaces)
{
    return '<f name="MrEavesModOT">' + digits + '</f>' +
        Array(spaces.length + 1).join(" ");
}
return Field("YOURFIELDHERE").replace(/(\d+)(\s*)/g, replace_helper);
Using MrEavesSanOT for your variable field in the text box.
__________________
Don Reimer - JavaScript Novice

MAC OS 10.13.6 Acrobat DC FP Creator 10.1.11
Windows 7 Acrobat X 10.1.4 FP Creator 9.3.9
Reply With Quote
Reply

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 01:51 AM.


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