mstanton Posted June 26, 2012 Posted June 26, 2012 Is there a way to apply a rule to an entire variable text frame so it applies to all the text and fields in it, rather than having to create the same rule for each element in the text box? Quote
Dan Korn Posted June 26, 2012 Posted June 26, 2012 Yes, there are several ways you can do this, depending on exactly what you're trying to accomplish. The simplest way is to simply set a single variable in the text frame, then create a rule with that same name to populate all the text. You can also use the frame properties API in OnRecordStart to set all the text in any named frame; something like this: FindTextFrame("YourFrameName").content = "here's some text";If you're simply trying to modify the style of all the text in the frame, you can use a <span> tag, either in a regular rule inserted before all the other text, like so: return '<span color="Green">';Or you can "inject" the formatting with the frame properties API in OnRecordStart, like so: FindTextFrame("YourFrameName").content = '<span color="Green">' + FindTextFrame("YourFrameName").contentIf you could be more specific as to exactly what you're trying to apply to the text in the frame, I could offer more specific suggestions. Quote
mstanton Posted June 27, 2012 Author Posted June 27, 2012 Since FusionPro doesn't handle the Proportional Lining OpenType feature, I have to change the font of just the numbers. Currently I have the following rule applied to each and every field that might have numbers in it: var numberFont = "Folio Light"; var numberWidth = "9"; var numberHeight = "8.5"; var text = Field("ADDRESS1"); return text.replace(/(\d+\s*)/g, function(d){return '<span font="' + numberFont + '"><z newsize="' + numberHeight + '"><setwidth newsize="' + numberWidth + '">' + d + '</span>';});It would be really nice if I could just have one or a couple of these rules rather than for every field. Thanks! Quote
Dan Korn Posted June 27, 2012 Posted June 27, 2012 Since FusionPro doesn't handle the Proportional Lining OpenType feature, I have to change the font of just the numbers. Currently I have the following rule applied to each and every field that might have numbers in it: var numberFont = "Folio Light"; var numberWidth = "9"; var numberHeight = "8.5"; var text = Field("ADDRESS1"); return text.replace(/(\d+\s*)/g, function(d){return '<span font="' + numberFont + '"><z newsize="' + numberHeight + '"><setwidth newsize="' + numberWidth + '">' + d + '</span>';});It would be really nice if I could just have one or a couple of these rules rather than for every field. Thanks! You can use "variable injection" to accomplish this, with the FusionPro.Composition.AddVariable function. Add this logic to OnRecordStart: var numberFont = "Folio Light"; var numberWidth = "9"; var numberHeight = "8.5"; for (var f in FusionPro.Fields) { var text = FusionPro.Fields[f].replace(/(\d+\s*)/g, function(d){return '<span font="' + numberFont + '"><z newsize="' + numberHeight + '"><setwidth newsize="' + numberWidth + '">' + d + '</span>';}); FusionPro.Composition.AddVariable(f, text, true) } Note that this will affect only fields called out directly in text frames or resources, not field values accessed in other rules with the Field function. Quote
mstanton Posted August 23, 2012 Author Posted August 23, 2012 Thanks! That works really well. Has saved me a TON of time! Quote
Recommended Posts
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.