Jump to content

Prevent line break


bstalcup

Recommended Posts

It depends on what you're trying to do. If you simply want to break

the line, a <br> tag will do the trick. On the other hand, the <p>

tag can have attributes specifying any of the properties shown in the

Paragraph Formatting dialog. You might also consider using a

Formatted Text Resource; if you leave the first line blank, it will

force a paragraph break.

Link to comment
Share on other sites

I'm not sure I agree with the statement that "the copyfitting features

of FusionPro do not work with the <br> tags included." It seems that

you're trying to do per-line copyfitting, which is a different kind of

copyfitting than the full-flow Copyfit that's activated in the Overflow

Options dialog and implemented in the OnCopyfit rule.

For per-line copyfitting, you need to use the CopyfitLine function. You

can find documentation about it in the Copyfitting Guide, which can be

found in the Knowledge Base at this link:

http://portal.knowledgebase.net/article.asp?article=178555&p=8481

 

Depending on what results you're trying to achieve, you may also want to

use the "Do not break on copyfit" option in the Paragraph Formatting

dialog, which will make sure that a paragraph does not break even when

the flow is being copyfitted. Of course, this is a paragraph setting,

so it only affects the paragraph as a whole, which means that it only

looks at <p> tags, not <br> tags.

Link to comment
Share on other sites

Alex, i'm not saying the <br> tag doesn't work. it does work. i haven't said that at all. my point is this: the copyfit for an entire field (Adjust text to fit/Allow text to expand to fill) stops working (not that <br> doesn't work) if i select one paragraph in the field and check "Do not break on copyfit".
Link to comment
Share on other sites

The short answer to your question is Yes, FusionPro does support several ways to prevent text from breaking. There's no "horizontal keep" tag, but you can use the   entity (non-breaking space) to prevent a set of words from breaking at line endings.

 

The simplest way to do this is to create a function like so in JavaScript:

 
function NoBreak(s)
{
 return NormalizeEntities(s).replace(/ /g, " ");
}

Then you can simply call this function for whatever phrase you don't want to break.

return NoBreak("My Product Name");

If you want to apply this "no break" logic to every instance of a field value from your input data, you can use the old "make a rule with the same name as the field to override it" trick. For instance, if you have a field named "Company Name", and you always want to keep it from breaking, you can make a rule with the same name as the field ("Company Name" in this example), and do this:

return NoBreak(Field("Company Name"));

A more robust solution would allow you to define a list of phrases which you don't want to break at all within a given bit of text. Here's an example of how to do that:

 
function NoBreak(s)
{
 return NormalizeEntities(s).replace(/ /g, " ");
}

var NoBreakPhrases =
 [ "My Company Name",
   "NonBreaking Product Name",
   // add as many as you like
 ];

function SetNoBreakPhrases(str)
{
   for (var p in NoBreakPhrases)
   {
       var re = new RegExp("(" + NoBreakPhrases[p] + ")", "gi")
       str = str.replace(re, function(w){return NoBreak(w);});
   }

   return str;
}

var s = "My Company Name would like to make you an offer for NonBreaking Product Name!";

return SetNoBreakPhrases(s);

 

You can put the functions and the NoBreakPhrases array in your JavaScript Globals if you need to use them in multiple rules.

 

Note that you'll need to turn off hyphenation for any paragraph into which you're setting this text as well. You can either do this with the Paragraph Formatting dialog, or you can have the function do it for you:

 
function NoBreak(s)
{
 return "<p br=false hyphenate=false noparabreakoncopyfit=true>" + NormalizeEntities(s).replace(/ /g, " ");
}

I should also mention that there is also a "Non-Breakable Phrases" option available from the Hyphenation Exceptions dialog (under FusionPro Desktop's Advanced menu), but that only affects jobs composed on that machine; in other words the list of phrases isn't kept with the job, so if your job is going to be composed remotely (such as with FP Direct or FP Web), that won't work for you.

Link to comment
Share on other sites

dan,

 

that was exactly what i needed, this resolved the issue in all scenarios except one.

 

we are merging some variable text with dollar amounts, like: 'Now $19.99'

 

at the customers request, we are automatically finding and superscripting all '$' characters. previously, we were getting wordwrap like:

 

'Now

$19.99'

 

now, with the non-breaking spaces, we are getting wordwrap like:

 

'Now $

19.99'

 

if we turn off the superscript on the '$' character, it stays all on one line.

 

why would superscripting part of a "word" (i'm guessing FusionPro views '$19.99' as one word) allow the "word" to be broken apart for wordwrapping?

Link to comment
Share on other sites

  • 9 months later...

I like where Dan is going, but I don't understand what the alternative is to breaking.

 

For instance, I have a CompanyName of "Caratted Oak View Inc."

I have CopyFit turned on. FP reports it cannot CopyFit that record.

So, "Inc." breaks to the next line.

 

If it cannot CopyFit, and I tell it to not Break, where would the "Inc." go?

Link to comment
Share on other sites

To further my example...

 

How would you use Dan's example in combination with my example?

 

I have a CompanyName of "Caratted Oak View Inc." (on a line by itself, no text before or after it)

I have CopyFit turned on, but it is too long to CopyFit. Soo, it breaks, but "Inc." goes on the next line by itself.

 

Is there a way to say, "If you can't CopyFit, then break near the middle of the data, or force at least two words to the next line?

Link to comment
Share on other sites

  • 5 weeks later...
...you can use the   entity...

 

The simplest way to do this is to create a function like so in JavaScript:

 
function NoBreak(s)
{
 return NormalizeEntities(s).replace(/ /g, " ");
}

Then you can simply call this function for whatever phrase you don't want to break.

 

We're trying this now and it's returning the literal characters   instead of translating it to a non-breaking space. What could be causing that?

Link to comment
Share on other sites

  • 2 years later...

When using this rule below combined with the font Frutiger 45 Light my text shows "MyProductName" - no spaces. When I switch to a different font like Arial or Tahoma then it's correct "My Product Name" - with spaces. Do you know why this works with most fonts but not all?

 

function NoBreak(s)

{

return NormalizeEntities(s).replace(/ /g, " ");

}

return NoBreak("My Product Name");

Link to comment
Share on other sites

When using this rule below combined with the font Frutiger 45 Light my text shows "MyProductName" - no spaces. When I switch to a different font like Arial or Tahoma then it's correct "My Product Name" - with spaces. Do you know why this works with most fonts but not all?

 

function NoBreak(s)

{

return NormalizeEntities(s).replace(/ /g, " ");

}

return NoBreak("My Product Name");

It's impossible to say without the font. Please do not post the font here, though. You can contact Support and they can work out a way for us to get the font to test.

Link to comment
Share on other sites

  • 4 months 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...