Jump to content

Font Color & Weight Changes in FusionPro


traba5058

Recommended Posts

All,

 

I need help.

 

I have a customer that can add up to 2 phone numbers on a business card. The field tags vary.

 

They need to bold the two phone tag fields and change the color for the divider between the 2 numbers if both are used.

 

I have Treat as Tagged Text selected.

 

I have tried both <b></b> and <f name=""></f>

 

My rule current rule is

if (Field("Phone 1") != "" && Field("Phone 2") != "")
   return <f name="Gotham Bold">Field("Phone 1 Tag")</f>+' '+Rule("Rule_FormatPhone")+' '+<color name="c0m36y100k8">|</color>+' '+<f name="Gotham Bold">Field("Phone 2 Tag")</f>+' '+Rule("Rule_FormatPhone2");
else if (Field("Phone 1") != "" && Field("Phone 2") == "")
   return <f name="Gotham Bold">Field("Phone 1 Tag")</f>+' '+Rule("Rule_FormatPhone");
else if (Field("Phone 1") == "" && Field("Phone 2") != "")
   return <f name="Gotham Bold">Field("Phone 2 Tag")</f>+' '+Rule("Rule_FormatPhone2");
else if (Field("Phone 1") == "" && Field("Phone 2") == "")
   return "";

 

When I check fonts used under advanced, I see Gotham Book and Gotham Bold I also see this in the text frame.

 

The color name for the color I want to use is c0m36y100k8. I see this in both the text frame color drop down as well as colors under advanced.

 

My phone format rules are formatting the numbers as (000) 000-0000.

 

I'm not getting any errors on compose, but it is returning the following:

 

Field("Phone 1 Tag") (404) 213-8360 | Field("Phone 2 Tag") (404) 941-2631

 

The whole line is black and there is no bold.

 

I appreciate any of the help I can get.

 

Thanks,

Traba

Link to comment
Share on other sites

All,

 

I updated my rule to

if (Field("Phone 1") != "" && Field("Phone 2") != "")
   return '<f name="Gotham Bold">Field("Phone 1 Tag")</f>'+' '+Rule("Rule_FormatPhone")+'  '+'<color name="c0m36y100k8">|</color>'+' '+'<f name="Gotham Bold">Field("Phone 2 Tag")</f>'+' '+Rule("Rule_FormatPhone2");
else if (Field("Phone 1") != "" && Field("Phone 2") == "")
   return '<f name="Gotham Bold">Field("Phone 1 Tag")</f>'+' '+Rule("Rule_FormatPhone");
else if (Field("Phone 1") == "" && Field("Phone 2") != "")
   return '<f name="Gotham Bold">Field("Phone 2 Tag")</f>'+' '+Rule("Rule_FormatPhone2");
else if (Field("Phone 1") == "" && Field("Phone 2") == "")
   return "";

 

And am getting the bold font & color changes. However, I've lost the space after the divider when 2 numbers are used and it is not showing the tag.

 

It's returning:

Field("Phone 1 Tag") (404) 213-8360 |Field("Phone 2 Tag") (404) 941-2631

with bold tags & yellow |. And missing the space between the | and phone 2 tag.

 

Any ideas?

Link to comment
Share on other sites

You need to be more careful with your quotes, so that the JavaScript engine knows what parts of your code are literal strings vs. function calls. You should be able to see what's being returned in the Rule Editor when you click Validate, without even composing, to see whether you're on the right track or not. And actually, even without clicking Validate, the syntax coloring in the Rule Editor should give you an idea of what's a literal string and what isn't. (You can click the Editor Settings button to change the Char Color and Strings Color settings to something with more contrast if that helps.)

 

This should work to keep the Field function calls from being output literally:

if (Field("Phone 1") != "" && Field("Phone 2") != "")
   return '<f name="Gotham Bold">' + Field("Phone 1 Tag") + '</f>'+' '+Rule("Rule_FormatPhone")+'  '+'<color name="c0m36y100k8">|</color>'+' '+'<f name="Gotham Bold">' + Field("Phone 2 Tag") + '</f>'+' '+Rule("Rule_FormatPhone2");
else if (Field("Phone 1") != "" && Field("Phone 2") == "")
   return '<f name="Gotham Bold">' + Field("Phone 1 Tag") + '</f>'+' '+Rule("Rule_FormatPhone");
else if (Field("Phone 1") == "" && Field("Phone 2") != "")
   return '<f name="Gotham Bold">' + Field("Phone 2 Tag") + '</f>'+' '+Rule("Rule_FormatPhone2");
else if (Field("Phone 1") == "" && Field("Phone 2") == "")
   return "";

Though you may also need to use entities or <space> tags in order to be able to output a space after a tag (such as </f>), so this should fix that:

if (Field("Phone 1") != "" && Field("Phone 2") != "")
   return '<f name="Gotham Bold">' + Field("Phone 1 Tag") + '</f><space>'+Rule("Rule_FormatPhone")+'  '+'<color name="c0m36y100k8">|</color><space>'+'<f name="Gotham Bold">' + Field("Phone 2 Tag") + '</f><space>'+Rule("Rule_FormatPhone2");
else if (Field("Phone 1") != "" && Field("Phone 2") == "")
   return '<f name="Gotham Bold">' + Field("Phone 1 Tag") + '</f><space>'+Rule("Rule_FormatPhone");
else if (Field("Phone 1") == "" && Field("Phone 2") != "")
   return '<f name="Gotham Bold">' + Field("Phone 2 Tag") + '</f><space>'+Rule("Rule_FormatPhone2");
else if (Field("Phone 1") == "" && Field("Phone 2") == "")
   return "";

I'll also note that there are several ways in which this code can be made simpler and more succinct. For instance:

var items = [];

if (Field("Phone 1"))
   items.push('<f name="Gotham Bold">' + Field("Phone 1 Tag") + '</f><space>' + Rule("Rule_FormatPhone"));

if (Field("Phone 2"))
   items.push('<f name="Gotham Bold">' + Field("Phone 2 Tag") + '</f><space>' + Rule("Rule_FormatPhone2"));

return items.join('  <color name="c0m36y100k8">|</color><space>');

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