Jump to content

How to use Oldstyle figures in FP


wrenchmaster

Recommended Posts

I did see this earlier... it is over my head actually.

Can this be explained any other way?

We have the font for the Alpha characters working but not the numbers.

In the address data, the street number and street name are combined in the record field, so we can't attribute the number separate from the name.

Edited by wrenchmaster
Link to comment
Share on other sites

Take a look at this post about Tabular Lining Characters here.

 

When needed, I've had success creating a new font with the Tabular Lining Characters put in the Regular Characters positions.

 

For example, copy the character one.tab and paste it in the character one position of a new font file. (Or whatever your oldstyle characters are named.) You'll need a font editor like TypeTool to accomplish this.

 

I also suggest checking the font's end user license agreement before doing this.

Edited by David Miller
Link to comment
Share on other sites

Bare with me, this is new territory for me.

So your saying to create the old style subset from the original font?

I may have an issue where our address field contains the number and street name combines. I can't separate the number from the name, so the entire variable would have the font assigned to it.

Link to comment
Share on other sites

We don't have tools to allow us to modify fonts. Is there any place that ould explain how to accomplish this?

We need the numbers in the address field to be OldStyle. The

address field has the number and name in one field.

 

Take a look at this post about Tabular Lining Characters here.

 

When needed, I've had success creating a new font with the Tabular Lining Characters put in the Regular Characters positions.

 

For example, copy the character one.tab and paste it in the character one position of a new font file. (Or whatever your oldstyle characters are named.) You'll need a font editor like TypeTool to accomplish this.

 

I also suggest checking the font's end user license agreement before doing this.

Link to comment
Share on other sites

Give this rule a shot:

 

return Field("Address").replace(/([0-9])/g, "ᢸ$1;").replace(/\s/g, " ");

 

You will need to turn on "Treat returned strings as tagged text" in the rule and also in the compose window, under the Advanced tab, turn off "Limit processing to Latin-1 text".

 

Note: the second replace is only needed if you have have digits separated by spaces, ie "564 897 S. Street". For whatever reason Fusion pushes the digits together too closely and using non breaking spaces fixes that.

Link to comment
Share on other sites

Can you explain how to use this?

 

I tried putting the field name and both font names above the line.

I then attached it as a javascript rule to the variable field.

 

The text does not change.

 

Copy and paste everything below this line:

 

// Edit the Field which to apply this function

// Change the name of the Font that you want to use for numbers and letters.

// If you use this Rule Inline, please be sure you style it Unique to the other fields,

// the last font tag to be written is for letters and may not be correct for the next word.

// You can get around this by styling the RuleName something totally unique and not used anywhere else.

//

 

var formatField = Field("address");

var fontNumber = "Courier New";

var fontLetter = "Helvetica";

 

//////////////////////////////////////////////////////////////////////////////////////////////////////

// DO NOT EDIT BELOW THIS LINE ///////////////////////////////////////////////////////////////////////

//////////////////////////////////////////////////////////////////////////////////////////////////////

//

//initialize the variable

//var formatThis = "201a Highway 101 #150";

//Call the Main function and pass it the Field to use.

//

return FormatAlphaNumeric(formatField);

//create function for formatting

function FormatAlphaNumeric(){

//check if Field is empty

if (formatField){

//if Field is not empty do this

//check if String contains a number

if (HasNumber(formatField)){

//if a number in the string, replace the numbers with the following font tags

//but also put the numbers back into place

formatField = formatField.replace(/(\d+)/g,"<f name=\""+fontNumber+"\">$1<f name=\""+fontLetter+"\">");

return formatField;

} else {

//if no number in the string say this

//return "The Variable formatThis has no number";

return formatField;

}

} else {

//if Field is empty say this

//return "The Variable formatThis is empty";

return formatField;

}

}

//create function for checking a string for number, anywhere

function HasNumber(testString){

var patternNumber = /\d/;

return patternNumber.test(testString);

}

//create function for checking a string for letter, anywhere

function HasLetter(testString){

var patternNumber = /\D/;

return patternNumber.test(testString);

}

 

 

 

 

You could include the letters and numbers in the new font file.

 

Or use a JavaScript Rule to return the letters in a different font than the numbers.

 

An example can be found here.

Link to comment
Share on other sites

I appreciate the help... where do I insert this rule when completed?

Is the in the place of the field variable?

 

Give this rule a shot:

 

return Field("Address").replace(/([0-9])/g, "ᢸ$1;").replace(/\s/g, " ");

 

You will need to turn on "Treat returned strings as tagged text" in the rule and also in the compose window, under the Advanced tab, turn off "Limit processing to Latin-1 text".

 

Note: the second replace is only needed if you have have digits separated by spaces, ie "564 897 S. Street". For whatever reason Fusion pushes the digits together too closely and using non breaking spaces fixes that.

Link to comment
Share on other sites

OK, now before I try it let me make sure I have all my ducks lined up...

 

Just to make sure you a clear on what I am trying to accomplish, I have rambled on in the post and it may be confusing.

 

I have a data field called [Delivery Address] which contains the street number and name.

 

The customer is using minion pro and the fonts are old style Tabular Oldstyle.

 

How will I set the font? Do I set it in the text editor at the variable name?

Link to comment
Share on other sites

OK, now before I try it let me make sure I have all my ducks lined up...

 

Just to make sure you a clear on what I am trying to accomplish, I have rambled on in the post and it may be confusing.

 

I have a data field called [Delivery Address] which contains the street number and name.

 

The customer is using minion pro and the fonts are old style Tabular Oldstyle.

 

How will I set the font? Do I set it in the text editor at the variable name?

 

Create a new rule called "rule_DeliveryAddress". Paste the code in as indicated but change the Field to Field("Delivery Address"). Check the box that says "Treat returned strings as tagged text".

 

Open text frame where you want the changed text and insert the «rule_DeliveryAddress» variable. Highlight it and change the font to Minion Pro.

 

Go to the compose dialog and the Advanced tab. Turn off the box that says "Limit processing to Latin-1 text". Let me know how it works.

Link to comment
Share on other sites

Doesn't seem to work, this is what I get.

 

Can you see the screen shot

 

Create a new rule called "rule_DeliveryAddress". Paste the code in as indicated but change the Field to Field("Delivery Address"). Check the box that says "Treat returned strings as tagged text".

 

Open text frame where you want the changed text and insert the «rule_DeliveryAddress» variable. Highlight it and change the font to Minion Pro.

 

Go to the compose dialog and the Advanced tab. Turn off the box that says "Limit processing to Latin-1 text". Let me know how it works.

Capture.jpg.644425ffd99137c28065cc4a61e0cc65.jpg

Link to comment
Share on other sites

Go back and look at my post with the script in it. It needs to be exactly as indicated. Notice how your post where you quoted me has the code messed up. If you copied and pasted from that, then it won't work.

oldstyle-numerals.jpg.d7b3f9d39078bbf3469b8eaffcda9945.jpg

Edited by ThomasLewis
Added screenshot. Where n represents a Field value.
Link to comment
Share on other sites

That worked!!!!!

 

I didn't notice the corruption.

 

Can I apply this to another rule for the ask amount variables?

 

 

Go back and look at my post with the script in it. It needs to be exactly as indicated. Notice how your post where you quoted me has the code messed up. If you copied and pasted from that, then it won't work.
Link to comment
Share on other sites

Can I apply this to another rule for the ask amount variables?

 

Sure. The only thing I would caution you on is this is specific to Minion Pro. It will probably work for other Adobe Pro fonts assuming they put the numerals in the same spot.

 

For future readers of this thread:

As Dan mentioned in the thread he pointed to earlier, there is no standard so it is impossible to predict where the numerical characters are. If you were to use this for other fonts you would need to find the unicode area where they are located using a program like Character Map and then get the ascii values. In this particular case it's a fortunate coincidence (or well planned) that the last character of the ascii value is the same as the numerical value, resulting in very a straight forward regex replacement.

Link to comment
Share on other sites

Now, when you have time can you explain what parts of the rule made it happen and how?

 

There's a lot of good information in the links in Dan's signature. You might take a look at some of those and also learn about regular expressions. They can get quite complex depending on what you want to do.

 

Basically in this case we are just finding any digit 0-9 and replacing it with the ascii code for the oldstyle number.

 

Example for this specific case with Minion Pro:

(These should have an & in front of the # but the forums seem to hate this)

0 = #63280;

1 = #63281;

2 = #63282;

etc.

 

The $1 is a placeholder for what the replacement found, ie if it found a 3 then $1 is a 3.

As I mentioned earlier, this may not always be the case depending on where the font creator decides to put those figures.

Edited by ThomasLewis
Link to comment
Share on other sites

Here's an updated version that should work with any ascii positions. Simply find the ascii number where the 0 is.

 

For many Adobe Pro fonts the tabular oldstyle 0 is at 63043 and proportional oldstyle 0 is at 63280.

 

//numerical ascii position without the 
var ascii = 63043;

var n = "1234 S. Street, Suite 567";

return n.replace(/([0-9])/g, function(str, n) {return "" + (parseInt(n) + ascii) + ";";}).replace(/\s/g, " ");

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