View Full Version : Changing font color of text frame

January 13th, 2010, 01:30 PM

I've been trying to figure out a way to change all of the text within a text frame based on the contents of a field using an OnRecordStart callback rule. So far no luck. Basically, I have a text frame with several variables in it using a white font on top of a graphic frame. I need to be able to change the font color depending on the background image that gets loaded into the graphic frame, since several have a white background.

Any help is appreciated.

Dan Korn
January 13th, 2010, 03:22 PM
In FusionPro 6.0 or later, you can name the text frame and then do something like this in OnRecordStart:
var myFrame = FindTextFrame("Story");
myFrame.content = "<span color=Green>" + myFrame.content;However, there's a somewhat simpler solution that will work in any (currently supported) version of FusionPro, without creating an OnRecordStart rule. You can just create a regular text rule like so:
return "<span color=Red>";
// Don't forget to check "Treat returned strings as tagged text." Then you can insert the variable with the rule's name at the very start of the text in the frame (in the Variable Text Editor).

To use a color name from a data field, just change the rule to do something like this:
return '<span color="' + Field("TextColor") + '">';

January 13th, 2010, 04:29 PM
I can't believe I wasted so much time and all I needed was "span"! I was trying to do it the same way you have it except I wasn't using that one little word. What a relief to be past that issue. Thanks for the help.

Dan Korn
January 14th, 2010, 09:03 AM
I'm glad I could help. For reference:
Mysteries of the <span> tag revealed (http://forums.printable.com/showthread.php?t=580)