Jump to content

Why are TextColor and TextFont not working for me?

Recommended Posts

I have a calculation field called 'zpastableMESSAGE' the entire content of whose calculation is as follows:

TextSize ( TextColor (TextFont (zMESSAGE ; zMessageTextFont ) ; zMessageTextColor ) ;zMessageTextSize)

(1) the field 'zMessageTextSize' is a text field, and whatever numeric value I enter into it is being used as TextSize, and correctly changes the size of the text displayed in the field 'zMESSAGE'

(2) the Calculation fields 'zMessageTextColor' and 'zTestMessageTextFont' at present contain values RGB(0,128,0) and "Krazy Kracks NF" respectively, BUT ARE BEING IGNORED (that is, the text in field 'zMESSAGE' is NOT HAVING those values applied).

But, if I replace those fields with the values that are currently in those fields, like this IT WORKS:

TextSize ( TextColor (TextFont (zMESSAGE ; "Krazy Kracks NF" ) ; RGB(250;0;0) ) ;zMessageTextSize)

Why would the Calculation fields not work when their values do?  A copy of a calculation that works would greatly help me.

Thanks in advance.   Philip Caplan

Link to post
Share on other sites
16 hours ago, philipcaplan said:

Why would the Calculation fields not work when their values do? 

Because there is a difference between literal text and formula.

If some field - be it a calculation field or a regular field - contains the text RGB(250;0;0) and you try to use this field in a calculation as: 

TextColor ( "any text" ; SomeField )

then Filemaker will interpret this as:

TextColor ( "any text" ; "RGB(250;0;0)" )

(note the quotes). Then Filemaker will try and convert the text "RGB(250;0;0)" to a color number and get a result of -25000. And since negative numbers are meaningless in this context, the color will be the default 0, i.e. black.

OTOH, when you do:

TextColor ( "any text" ; RGB ( 250 ; 0 ; 0 ) ) 

Filemaker will interpret the second argument as a formula that needs to be evaluated further, and interpret this as:

TextColor ( "any text" ; 16384000 ) 

giving your text a bright red color.


To give you a simpler example, suppose you have a text field that contains the text 2 + 2. Using this field in a calculation as =

10 + Textfield

will return 32, same as:

10 + "2 + 2"


I hope this doesn't add further confusion to the issue, but it needs to be mentioned that Filemaker has a function for converting literal text to a formula. In the current example:

10 + Evaluate ( Textfield )

will return 14.


All of the above applies to the TextColor() function. I don't think you should have any problems supplying the font name as literal text.


Edited by comment
Link to post
Share on other sites

I think I've got it to work!!   I used the following calculation:

TextSize ( TextColor (TextFont (zMESSAGE ; zMessageTextFont ) ; Evaluate(zMessageTextColor) ) ;zMessageTextSize)

Thank you.


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
  • Create New...

Important Information

By using this site, you agree to our Terms of Use.