ScottHillock Posted April 9, 2019 Posted April 9, 2019 I'm looking to create a rule that will replace all occurrences of a string of text, even when that text is not part of a rule. Specifically we're having an issue where the notdef symbol is being inserted when some fonts don't have the character. I'd like to replace the font for this character to one which does have the glyph defined. I know how to make this change when the text is returned from a rule. I'm just looking for the FusionPro way of searching through all text frames and replacing characters. Quote
Dan Korn Posted April 16, 2019 Posted April 16, 2019 FusionPro VDP 10.1 has a cool new text replacement feature, which does exactly what you want: globally replace all occurrences of any text in the job. You can even do this without writing any JavaScript code, with the new "Global Replace Text" XML Template callback rule. However, in this, case, since the text you're replacing is the "special" non-breaking space character, you do have to use JavaScript, but handling that character is easy enough with the RawTextFromTagged function. So, in FusionPro 10.1, you can do this in OnJobStart, replacing the font name with whatever font you want: FusionPro.Composition.AddTextReplacement(RawTextFromTagged(" "), '<span font="Times New Roman"> </span>'); That said, I suspect this is all a bit of an "XY problem," where what you're really trying to do is accomplish non-breaking text, and you're doing this by inserting entities. But there's a better way to accomplish non-breaking text, or what we prefer to call a "horizontal keep," in FusionPro 10.1, with <hkeep> and </hkeep> tags. (And really, the font shouldn't be trying to output an character anyway; there's no glyph to draw for white space. That's part of why we have the <hkeep> tag now.) It's not clear to me exactly what you're doing with the entities, nor how you're inserting them, but you should be able to rework whatever logic you have that's relying on the entities to use the tags instead. If you have just a particular phrase that you want to never break in your job, you can use another handy XML Template callback rule, "Format Specific Word or Phrase", and simply check the "Don't break or hyphenate" box (which inserts <hkeep> and </hkeep> tags). If you are doing something more complicated with programmatically inserting tags in a rule, then you will have to modify that rule to use the tags instead. For instance, where previously you would have markup like this: return "Never break this text"; You can now do this: return "<hkeep>Never break this text</hkeep>"; The bottom line is, with FusionPro 10.1, in my opinion, the real solution is to use <hkeep> and </hkeep> tags instead of in the first place. Quote
ScottHillock Posted April 16, 2019 Author Posted April 16, 2019 (edited) Excellent Dan, thank you. I'll keep in mind the <hkeep> tags when I need them. The character accidentally shows up sometimes in FusionPro text frames when the InDesign source document has returns with a normal space on an empty line. So ^p ^p ends up turning into ^p ^p. I have a few InDesign scripts to clean things up for FusionPro but on some documents we can't run the scripts, so I was looking for an automated solution to fix the notdef character from basically ever showing up in a document with a character. Edited April 16, 2019 by ScottHillock Quote
Dan Korn Posted April 16, 2019 Posted April 16, 2019 Excellent Dan, thank you. I'll keep in mind the <hkeep> tags when I need them. Okay. Though your signature says you're still running FusionPro 9.3. Everything I mentioned requires 10.1 or later. The character accidentally shows up sometimes in FusionPro text frames when the InDesign source document has returns with a normal space on an empty line. So ^p ^p ends up turning into ^p ^p. I'd love to take a look at one of these InDesign documents. I have a few InDesign scripts to clean things up for FusionPro but on some documents we can't run the scripts, so I was looking for an automated solution to fix the notdef character from basically ever showing up in a document with a character. Well, I think the code I posted with the call to FusionPro.Composition.AddTextReplacement would work. But I can't really try it without one of your InDesign files. Quote
Dan Korn Posted April 16, 2019 Posted April 16, 2019 Also, you might be able to get the to work with your font by simply unchecking the "Limit to Latin-1" or "Limit to Mac Roman" box, as Steve Davenport notes here: http://forums.pti.com/showthread.php?t=5328 Quote
ScottHillock Posted April 17, 2019 Author Posted April 17, 2019 Dan, sample files attached. Unchecking the Limit processing to.. checkbox does make the notdef character not appear. And it's a viable solution. But, I usually leave that checked to make sure the data source doesn't contain characters that might cause issues on output. But, I should probably move that "checking" to a different workflow process. We do have FusionPro 9, so the <hkeep> and AddTextReplacement aren't available to us to use yet, but we're looking at the upgrade to 10 in the near future.Archive.zip 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.