Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Rich Text Format Line Spacing

Tags:

c#

rtf

I try to convert a plain text in RTF-Format. Therefore, I use RichTextBox (WinForms).
The concerned method the RTF-Markup as string.

Now, I want to insert line spacing in the markup. I found that there are 2 parameters:

 - \slX (Space between lines in twips)
 - \slmultX (either 0 or 1)

If I set \slmult0, the line spacing is above the line of text.
When I set \slmult1, the line spacing is below the line of text.

I calculate the spacing in the following way:

(lineSpacing + fontSize)*20

When I switched from \slmult0 to \slmult1, I determined, that the line distance is little smaller than with \slmult0.

Does somebody know the reason for this behavior? Do I have to calculate with another formula?

like image 270
Chris2011931 Avatar asked Jul 22 '15 11:07

Chris2011931


People also ask

How much space should be between text lines?

The traditional term for line spacing is leading (rhymes with bedding ), so named because traditional print shops put strips of lead between lines of type to increase vertical space. Sometimes you see this term in typesetting software. For most text, the optimal line spacing is between 120% and 145% of the point size.

What is considered a rich text format?

What is Rich Text Format (RTF)? Rich Text Format (RTF) is a file format that lets you exchange text files between different word processors in different operating systems (OSes). For example, you can create a file in Microsoft Word and then open it in another word processor, such as Apple Pages or Google Docs.

Does rich text allow formatting?

If you enable rich-text formatting for a rich text box, users can use a variety of options to format the text that they enter in that control. For example, they can apply a different font or character style to the text inside the rich text box or even insert a table into the rich text box.

How do I change the line spacing in a writer?

Changing the line spacing in OpenOffice Writer To change the line spacing in OpenOffice Writer, follow the steps below. On the right side of the window, click the blue and green Properties box to show the properties of the page. Under Spacing, click the Increase Spacing button.


1 Answers

If I set \slmult0, the line spacing is above the line of text. When I set \slmult1, the line spacing is below the line of text.

That is not what I read in the specs.

The way I understand it, it means that \slmult0 says that the value of \slN is to be used directly as a distance in some unit, whereas \slmult1 says the N in \slN is meant as a factor by which the regular line spacing is multiplied.

See the last post here for (some) more details! (But there is also a note about it taking effect one line too late..)

Also do note the importance of the sign of N in the \slN! (This was the reason of my comment above: The effect of, say \sl234, will depend on the size of the tallest character in the line..!)

Here is a nice discussion of some things RTF; a note about units:

Measurements in RTF are generally in twips. A twip is a twentieth of a point, i.e., a 1440th of an inch. That leads to some large numbers sometimes (like \li2160, to set the left indent to an inch and a half)

and a clear definition of extra spacing before and after paragraphs:

\sbN -- N twips of extra (vertical) space before this paragraph (default: 0)
\saN -- N twips of extra (vertical) space after this paragraph (default: 0)

Here are more direct instructions:

To double-space a paragraph, put the code \sl480\slmult1 right after the \pard. To triple-space it, use \sl720\slmult1. To have just 1.5-spacing, use \sl360\slmult1. A single-spaced paragraph is the default, and doesn’t need any particular code. (The magic numbers 480, 720, and 360 don’t depend on the point size of the text in the paragraph.)

like image 136
TaW Avatar answered Oct 20 '22 01:10

TaW