Page 1 of 1

Problem with fixed width text

Posted: Fri Dec 14, 2007 5:24 pm
by igoddard
I need to paste a couple of very wide fixed width data lines into a document in order to write a commentary on them.

If I do that they have to be wrapped to fit between the margins but the wrapping takes place on the last space character before the margin. Even worse, it then hides any further spaces before the next non-space character.

For ordinary text this is just what's needed but in order to maintain vertical alignment between equivalent bits of the lines I need to wrap at the margins irrespective of spaces. I could force this by inserting returns at the margins but that would complicate matters for anyone who wishes to cut and paste the text in order to retrieve the original format.

What I need is a means of marking a para as "wrap text at margin" but I can't see any option for doing this? Is there anything in there which would do the trick?

TIA

Ian

Re: Problem with fixed width text

Posted: Fri Dec 14, 2007 7:49 pm
by acknak
I would either make the fixed-width font small enough to avoid line breaks, or add the line breaks myself (Shift+Enter).

You could also try replacing all the spaces with non-breaking spaces (Ctrl+Space), or even a "graphic space" such as U+2423: ␣

Re: Problem with fixed width text

Posted: Fri Dec 14, 2007 8:31 pm
by foxcole
I'm not sure this will work, but is worth a try. Insert a blank paragraph and apply the "Preformatted Text" preset style, then copy the text, click in the Preformatted Text blank paragraph, and choose Edit> Paste special> Unformatted text. Does that work?

Re: Problem with fixed width text

Posted: Sat Dec 15, 2007 12:16 pm
by igoddard
foxcole wrote:I'm not sure this will work, but is worth a try. Insert a blank paragraph and apply the "Preformatted Text" preset style, then copy the text, click in the Preformatted Text blank paragraph, and choose Edit> Paste special> Unformatted text. Does that work?
Preformatted Text sounds right (I think that's what it was called in M/$ Worm) but I can't find that as a format option. Is it there & if so, where's it hidden? BTW I'm on 2.3.1.

Ian

Re: Problem with fixed width text

Posted: Sat Dec 15, 2007 12:29 pm
by igoddard
acknak wrote:I would either make the fixed-width font small enough to avoid line breaks, or add the line breaks myself (Shift+Enter).

You could also try replacing all the spaces with non-breaking spaces (Ctrl+Space), or even a "graphic space" such as U+2423: ␣
Smaller fonts were my first thought until I realised the lines were so long I'd need a font about 2 pixels wide! Adding the line breaks didn't help as much as I'd thought - the formatting still plays tricks where runs of spaces get truncated. Non-breaking spaces might be the answer if I can't work out how to apply foxcole's solution. At the minute I've got a lazy man's version of that in use - I went into the original file with vi & did a bulk replace of all spaces with underscores but it's ugly. Nevertheless the underscores will be easy to replace with nbs's.

Ian

Re: Problem with fixed width text

Posted: Sat Dec 15, 2007 6:06 pm
by Bill
igoddard wrote:
acknak wrote:I would either make the fixed-width font small enough to avoid line breaks, or add the line breaks myself (Shift+Enter).

You could also try replacing all the spaces with non-breaking spaces (Ctrl+Space), or even a "graphic space" such as U+2423: ␣
Smaller fonts were my first thought until I realised the lines were so long I'd need a font about 2 pixels wide! Adding the line breaks didn't help as much as I'd thought - the formatting still plays tricks where runs of spaces get truncated. Non-breaking spaces might be the answer if I can't work out how to apply foxcole's solution. At the minute I've got a lazy man's version of that in use - I went into the original file with vi & did a bulk replace of all spaces with underscores but it's ugly. Nevertheless the underscores will be easy to replace with nbs's.

Ian
As far as I know, "Preformatted Text" is just a paragraph style like any other. There is nothing special about this paragraph style which would change the way lines wrap--wrapping still occurs only at spaces between words. "Preformatted Text" is the paragraph style which is applied automatically when opening a TXT file--which has no formatting information.

Try acknak's suggestion of replacing the spaces with non-breaking spaces. It has the same effect on wrapping as replacing spaces with underscores and visually there is no difference between a regular space and a non-breaking space. It's easy to do and it works.

Re: Problem with fixed width text

Posted: Sun Dec 16, 2007 12:52 am
by igoddard
Bill wrote:
igoddard wrote:
acknak wrote:I would either make the fixed-width font small enough to avoid line breaks, or add the line breaks myself (Shift+Enter).

You could also try replacing all the spaces with non-breaking spaces (Ctrl+Space), or even a "graphic space" such as U+2423: ␣
Smaller fonts were my first thought until I realised the lines were so long I'd need a font about 2 pixels wide! Adding the line breaks didn't help as much as I'd thought - the formatting still plays tricks where runs of spaces get truncated. Non-breaking spaces might be the answer if I can't work out how to apply foxcole's solution. At the minute I've got a lazy man's version of that in use - I went into the original file with vi & did a bulk replace of all spaces with underscores but it's ugly. Nevertheless the underscores will be easy to replace with nbs's.

Ian
As far as I know, "Preformatted Text" is just a paragraph style like any other. There is nothing special about this paragraph style which would change the way lines wrap--wrapping still occurs only at spaces between words. "Preformatted Text" is the paragraph style which is applied automatically when opening a TXT file--which has no formatting information.

Try acknak's suggestion of replacing the spaces with non-breaking spaces. It has the same effect on wrapping as replacing spaces with underscores and visually there is no difference between a regular space and a non-breaking space. It's easy to do and it works.
"Preformatted text" in Word AFAICR does what I was looking for. All I can find in Writer is "Text" which works as you say.

I've tried the NBS substitution. It has an odd effect in formatting. If wrapping would place one or more spaces at the start of the wrapped text the first such space isn't wrapped but left beyond the margin at the end of the previous line. The result is that if a line wraps at the start or in the middle of a run of one or more space characters it ends up with one more character on it than it ought to have before it wraps. As this is a space character it's not visually intrusive but potentially it would break the vertical alignment. As it is I've got away with it because, as luck would have it, both my data rows are affected in exactly the same places. If, however, the reader tries counting the characters & comparing them with the layout spec they'll find some odd discrepancies because they'll miss some of the spaces. Also, it's not possible to cut and paste out of it into a vanilla text file as the nbs characters come out as octal values.

I have a nasty feeling that I'm going to have to do this in Word. :o

Ian

Re: Problem with fixed width text

Posted: Mon Dec 17, 2007 5:13 pm
by foxcole
Bill wrote:As far as I know, "Preformatted Text" is just a paragraph style like any other. There is nothing special about this paragraph style which would change the way lines wrap--wrapping still occurs only at spaces between words.
I thought perhaps because it's part of the built-in set of styles, and because some things in Writer are hard-coded, they may have created a special style that actually does perform the "preformatted text" function. It's normally used for copying text into HTML (within a <PRE> tag) while maintaining its appearance... meaning, "as is" with all the spaces, tabs, indenting, etc. exactly as in the original. Because XML uses similar tags, I thought it was worth a shot.
igoddard wrote:Smaller fonts were my first thought until I realised the lines were so long I'd need a font about 2 pixels wide!
:?: :?: :?:
How long are these lines of text, exactly? If the font would need to go that small, how would you fit the lines on a page in the first place? Now I'm confused.

Re: Problem with fixed width text

Posted: Mon Dec 17, 2007 5:38 pm
by huw
foxcole wrote:How long are these lines of text, exactly? If the font would need to go that small, how would you fit the lines on a page in the first place? Now I'm confused.
I think the lines are to be treated as strings of characters, rather than words, and wrapped at n characters regardless of whether that is in the middle of a word, before a space, or after. The wrap must not remove even a space at the beginning or end of a line.

It must look somewhat like viewing a file with a hex editor. Even pure text email software that wraps at 72 (or similar) characters will break at a space between words.

I don't even know what this type of "wrap" is called. Certainly not "word wrap". The only clear reference I can find to it is an obscure PowerPoint bug and its even more obscure fix.
http://www.mraggarwal.com/2007/05/11/po ... he-middle/

Re: Problem with fixed width text - solved, sort of

Posted: Mon Dec 17, 2007 6:58 pm
by igoddard
foxcole wrote:
:?: :?: :?:
How long are these lines of text, exactly? If the font would need to go that small, how would you fit the lines on a page in the first place? Now I'm confused.
How long? 300 characters plus. They're examples of a data file. I'm writing up the formats for the developers to work out how to parse them - frankly it would be easier to write the code myself. As it seems there isn't a suitable style I'll settle for using non-breaking spaces and send them a copy of the file itself. The handling of wraps involving NBS seems odd. Maybe I'll put in a bug report.

Ian