Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Setting the Line Height/ Line Spacing in an NSTextView

How would I set the Line Height or Line Spacing in an NSTextView (i.e. how tall each line is, or how much space is between each line)?

like image 607
Joshua Avatar asked Dec 24 '09 12:12

Joshua


People also ask

What is line spacing and line height?

Line height, also known as leading, is the distance between each line when you have two or more rows of text. Letter spacing, also known as tracking, is the size of the gaps between each letter of each word.

How do you calculate line spacing height?

For most text, the optimal line spacing is between 120% and 145% of the point size. Most word processors, as well as CSS, let you define line spacing as a multiple. Or you can do the math—multiply your point size by the percentage.

What is the ideal line spacing?

Line spacing should be at least a space-and-a-half within paragraphs. So around 150 percent or 1.5 times the font size. Spacing following paragraphs should be at least two times the font size.


1 Answers

leave the answer in case someone need:

NSMutableParagraphStyle * myStyle = [[NSMutableParagraphStyle alloc] init];
[myStyle setLineSpacing:10.0];
[myTextView setDefaultParagraphStyle:myStyle];
like image 166
Jiulong Zhao Avatar answered Oct 11 '22 21:10

Jiulong Zhao