Jump to content

Recommended Posts

Posted
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?
Posted

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").content

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

Posted

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!

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

  • 1 month later...
  • 1 year later...

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