Jump to content

Using Multiple Fonts in a single field


inxcapable

Recommended Posts

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!

Link to comment
Share on other sites

  • 1 month later...

I used this in the past. May work.

 

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.

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