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

Notices

Reply
 
Thread Tools Search this Thread Display Modes
  #1  
Old September 6th, 2012, 01:59 PM
Meir Meir is offline
Regular Contributor
 
Join Date: Mar 2011
Location: Lawrenceville, NJ
Posts: 50
Question Tracking a Dollar Sign

Hey,

I am trying to add tracking to a price (i.e. $11.99). I only want to track 1's and $'s.

I've been trying several versions of the following code.

Code:
var Num = '5';
var Price ='$'+Field("Price"+Num)

return NormalizeEntities(Price).replace(/(1)($)/g, "<tracking newsize=-20>$1</tracking>");
This returns
Quote:
$<tracking newsize=-20>1</tracking><tracking newsize=-20>1</tracking>.49
Notice how the dollar sign does not receive tracking.

Any advice on how I can get it to track?

Kerning may be an alternate solution. I have it check on in the text box but it does not change anything.

Thank you for any and all help!
__________________
Meir Galimidi
Allegra
FP 7.2P1k, MAC OSX 10.5.8, Acrobat 9.4.0
Reply With Quote
  #2  
Old September 6th, 2012, 02:53 PM
ThomasLewis's Avatar
ThomasLewis ThomasLewis is offline
Senior Contributor
 
Join Date: Feb 2011
Posts: 233
Default Re: Tracking a Dollar Sign

Code:
return NormalizeEntities(Price).replace(/\$1/g, "<tracking newsize=-20>$1</tracking>");
That worked for me, although Dan is the resident regex guru
Reply With Quote
  #3  
Old September 6th, 2012, 03:19 PM
Meir Meir is offline
Regular Contributor
 
Join Date: Mar 2011
Location: Lawrenceville, NJ
Posts: 50
Default Re: Tracking a Dollar Sign

Thank you very much Thomas. I had tried it without the '\' but the slash did the trick.

Now my issue is that it is outputting this
Quote:
<tracking newsize=-20>$1</tracking>1.49
It is not formatting the second instance of the number '1'.

I could fix this by adjusting it to
Code:
return NormalizeEntities(Price).replace(/(\$11)/g, "<tracking newsize=-20>$1</tracking>");
but because price will be a variable I want it correcting other instances as well.

I would only like to format '1' in all instances and '$' in instances where it comes before a '1'. So the above code works great for all instances I would format the '$' but leaves out all other '1' fixes (though I did not specify well enough and your answer put me much closer to the answer).

When I try
Code:
return NormalizeEntities(Price).replace(/(\$11)(1)/g, "<tracking newsize=-20>$1</tracking>");
OR
Code:
return NormalizeEntities(Price).replace(/(\$11)(\1)/g, "<tracking newsize=-20>$1</tracking>");
it returns
Quote:
$11.49
with no formatting.

Is there away to account for this in that line of code, or would it be best to create a function that figures out if the first number is a one. If it is a one, then it returns a variable equal to '$1' run through Thomas's replace tracking tag followed by everything to the right of the initial 1 being sent through my original tracking tag which adjusts all instances of the number 1.
__________________
Meir Galimidi
Allegra
FP 7.2P1k, MAC OSX 10.5.8, Acrobat 9.4.0
Reply With Quote
  #4  
Old September 6th, 2012, 03:49 PM
ThomasLewis's Avatar
ThomasLewis ThomasLewis is offline
Senior Contributor
 
Join Date: Feb 2011
Posts: 233
Default Re: Tracking a Dollar Sign

Code:
return NormalizeEntities(Price).replace(/(\$11|\$1)/g, "<tracking newsize=-20>$1</tracking>");
So to make this as confusing as possible $1 is what you use to remember what was replaced.

This sample shows that better:
Code:
return "ABC".replace(/(ABC|DEF)/g, "<tracking newsize=-20>$1</tracking>");
Reply With Quote
  #5  
Old September 6th, 2012, 03:57 PM
Meir Meir is offline
Regular Contributor
 
Join Date: Mar 2011
Location: Lawrenceville, NJ
Posts: 50
Default Re: Tracking a Dollar Sign

Has anyone told you that you are awesome lately, because you are.
That should work assuming they don't have any 1's after the decimal point, but based on that data I have they tend to stay toward the 99,79,59 type pricing.

Thank you.
__________________
Meir Galimidi
Allegra
FP 7.2P1k, MAC OSX 10.5.8, Acrobat 9.4.0
Reply With Quote
  #6  
Old September 6th, 2012, 04:10 PM
ThomasLewis's Avatar
ThomasLewis ThomasLewis is offline
Senior Contributor
 
Join Date: Feb 2011
Posts: 233
Default Re: Tracking a Dollar Sign

thanks! I have been known for the occasional blunder in these forums though but I appreciate the notion.

Now watch Dan follow up with the answer as elegant as return "42";
Reply With Quote
  #7  
Old September 10th, 2012, 12:24 PM
esmith esmith is offline
Senior Contributor
 
Join Date: Oct 2008
Location: Charlotte, NC
Posts: 869
Default Re: Tracking a Dollar Sign

Looks like you have a working solution, but another option I have begun using is to generate a custom version of the font with Fontographer where the spacing is adjusted for necessary character(s).

It may seem excessive at first, but it really opens up the possibility of what you can do with type. I have created "characters" for "stacked" type that says "% OFF" and then do a simple replace which allows me to include a faux-graphic inline and centered regardless of the dollar amount that comes before it. Very helpful.
Reply With Quote
  #8  
Old September 10th, 2012, 12:44 PM
Meir Meir is offline
Regular Contributor
 
Join Date: Mar 2011
Location: Lawrenceville, NJ
Posts: 50
Default Re: Tracking a Dollar Sign

Thank you for the advice Eric. That sounds like an interesting method to try. Can you clarify something for me though.

Would you create one font where, lets say the dollar symbol exists with different tracking as the displayed symbol for ever letter a, b, c, d, e, f, g...

Or is it many fonts are created where the dollar symbol has different tracking and is displayed when you type '$'

Have a great day!
__________________
Meir Galimidi
Allegra
FP 7.2P1k, MAC OSX 10.5.8, Acrobat 9.4.0
Reply With Quote
  #9  
Old September 10th, 2012, 03:42 PM
ThomasLewis's Avatar
ThomasLewis ThomasLewis is offline
Senior Contributor
 
Join Date: Feb 2011
Posts: 233
Default Re: Tracking a Dollar Sign

Those are kerning pairs and you can reset them. I agree with Eric, sometimes it is a lot easier to just change the font than try to program around it. I use FontLab though personally, I think it's a little easier to mess with for OpenType stuff.
Reply With Quote
  #10  
Old September 12th, 2012, 03:00 PM
esmith esmith is offline
Senior Contributor
 
Join Date: Oct 2008
Location: Charlotte, NC
Posts: 869
Default Re: Tracking a Dollar Sign

Quote:
Originally Posted by Meir View Post
Would you create one font where, lets say the dollar symbol exists with different tracking as the displayed symbol for ever letter a, b, c, d, e, f, g...

Or is it many fonts are created where the dollar symbol has different tracking and is displayed when you type '$'
I'm not sure I understand what you are asking. For my example, I have a client who uses the FolioMedium font. They want the dollar sign to be superscripted, but we ran into problems where a price would break between the numbers when adding the superscript tags in FP. Instead, we made the dollar sign smaller in a copy of the font: FolioMedium-Custom. Now, instead of adding a tag and risking an unwanted line break, we just replace the font for the dollar sign.

Also, since numbers are usually monospaced (to allow digits to line up when used in columns) the "1" typically has too much space built in to its character. I simply edit the "width" of the space to the left/right of the character to force adjacent characters to be positioned closer to the "1". I can do this for any character in the custom-named font. If for some reason I want the original spacing (like in the column example above), I simply use the original font again.
Reply With Quote
Reply

Tags
kerning, newsize, tracking

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 11:56 PM.


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