Important: The information in this document is obsolete and should not be used for new development.
Inherits from | |
Implements | |
Package | com.apple.cocoa.application |
Companion guide |
NSParagraphStyle and its subclass NSMutableParagraphStyle encapsulate the paragraph or ruler attributes used by the NSAttributedString classes. Instances of these classes are often referred to as paragraph style objects or, when no confusion will result, paragraph styles.
The mutable subclass of NSParagraphStyle is NSMutableParagraphStyle.
alignment
firstLineHeadIndent
headIndent
tailIndent
tabStops
defaultTabInterval
lineHeightMultiple
maximumLineHeight
minimumLineHeight
lineSpacing
paragraphSpacing
paragraphSpacingBefore
Returns the default paragraph style.
public static NSParagraphStyle defaultParagraphStyle
()
The default paragraph style has the following default values:
Subattribute |
Default Value |
---|---|
Alignment |
|
Tab stops |
12 left-aligned tabs, spaced by 28.0 points |
Line break mode |
|
All others |
0.0 |
See individual method descriptions for explanations of each subattribute.
Returns the default writing direction for languageName.
public static int defaultWritingDirectionForLanguage
(String languageName)
languageName is in ISO language region format. Possible return values are described in “Constants.”
baseWritingDirection
setBaseWritingDirection
(NSMutableParagraphStyle)Returns the text alignment of the receiver.
public int alignment
()
Text alignment is one of:
NSText.LeftTextAlignment
NSText.RightTextAlignment
NSText.CenterTextAlignment
NSText.JustifiedTextAlignment
NSText.NaturalTextAlignment
Natural text alignment is realized as left or right alignment depending on the line sweep direction of the first script contained in the paragraph.
setAlignment
(NSMutableParagraphStyle)Returns the base writing direction for the receiver. Possible return values are described in “Constants.”
public int baseWritingDirection
()
defaultWritingDirectionForLanguage
setBaseWritingDirection
(NSMutableParagraphStyle)Returns the document-wide default tab interval.
public float defaultTabInterval
()
Tabs after the last specified in tabStops
are placed at integer multiples of this distance (if positive). Default return value is 0.0.
setDefaultTabInterval
(NSMutableParagraphStyle)Returns the distance in points from the leading margin of a text container to the beginning of the paragraph’s first line.
public float firstLineHeadIndent
()
This value is always nonnegative.
headIndent
tailIndent
setFirstLineHeadIndent
(NSMutableParagraphStyle)Specifies whether the paragraph is to be treated as a header for purposes of HTML generation.
public int headerLevel
()
Returns 0 (the default value), if the paragraph is not a header, or from 1 through 6 if the paragraph is to be treated as a header.
setHeaderLevel
(NSMutableParagraphStyle)Returns the distance in points from the leading margin of a text container to the beginning of lines other than the first.
public float headIndent
()
This value is always nonnegative.
firstLineHeadIndent
tailIndent
setHeadIndent
(NSMutableParagraphStyle)Returns the paragraph’s threshold for hyphenation.
public float hyphenationFactor
()
Valid values lie between 0.0 and 1.0 inclusive. The default value is 0.0. Hyphenation is attempted when the ratio of the text width (as broken without hyphenation) to the width of the line fragment is less than the hyphenation factor. When the paragraph’s hyphenation factor is 0.0, the layout manager’s hyphenation factor is used instead. When both are 0.0, hyphenation is disabled.
setHyphenationFactor
(NSMutableParagraphStyle)Returns the mode that should be used to break lines when laying out the paragraph’s text.
public int lineBreakMode
()
See “Constants” for a list of values.
setLineBreakMode
(NSMutableParagraphStyle)Returns the line height multiple.
public float lineHeightMultiple
()
The natural line height of the receiver is multiplied by this factor (if positive) before being constrained by minimum and maximum line height. Default return value is 0.0.
maximumLineHeight
minimumLineHeight
setLineHeightMultiple
(NSMutableParagraphStyle)Returns the space in points added between lines within the paragraph (commonly known as leading).
public float lineSpacing
()
This value is always nonnegative.
maximumLineHeight
minimumLineHeight
paragraphSpacing
setLineSpacing
(NSMutableParagraphStyle)Returns the maximum height that any line in the receiver will occupy, regardless of the font size or size of any attached graphic.
public float maximumLineHeight
()
Glyphs and graphics exceeding this height will overlap neighboring lines; however, a maximum height of 0 implies no line height limit. This value is always nonnegative. The default value is 0.
Although this limit applies to the line itself, line spacing adds extra space between adjacent lines.
minimumLineHeight
lineSpacing
lineHeightMultiple
setMaximumLineHeight
(NSMutableParagraphStyle)Returns the minimum height that any line in the receiver will occupy, regardless of the font size or size of any attached graphic.
public float minimumLineHeight
()
This value is always nonnegative.
maximumLineHeight
lineSpacing
lineHeightMultiple
setMinimumLineHeight
(NSMutableParagraphStyle)Returns the space added at the end of the paragraph to separate it from the following paragraph.
public float paragraphSpacing
()
This value is always nonnegative. Determined by adding the previous paragraph’s paragraphSpacing
and the current paragraph’s paragraphSpacingBefore
.
lineSpacing
setParagraphSpacing
(NSMutableParagraphStyle)Returns the distance between the paragraph’s top and the beginning of its text content.
public float paragraphSpacingBefore
()
Default return value is 0.0.
paragraphSpacing
setParagraphSpacingBefore
(NSMutableParagraphStyle)Returns the NSTextTab objects, sorted by location, that define the tab stops for the paragraph style.
public NSArray tabStops
()
location
(NSTextTab)setTabStops
(NSMutableParagraphStyle)addTabStop
(NSMutableParagraphStyle)removeTabStop
(NSMutableParagraphStyle)Returns the distance in points from the margin of a text container to the end of lines.
public float tailIndent
()
If positive, this value is the distance from the leading margin (for example, the left margin in left-to-right text). If 0 or negative, it’s the distance from the trailing margin.
For example, a paragraph style designed to fit exactly in a 2-inch wide container has a head indent of 0.0 and a tail indent of 0.0. One designed to fit with a quarter-inch margin has a head indent of 0.25 and a tail indent of –0.25.
headIndent
firstLineHeadIndent
setTailIndent
(NSMutableParagraphStyle)Returns an array specifying the text blocks containing the paragraph, nested from outermost to innermost.
public NSArray textBlocks
()
setTextBlocks
(NSMutableParagraphStyle)Returns an array specifying the text lists containing the paragraph, nested from outermost to innermost.
public NSArray textLists
()
setTextLists
(NSMutableParagraphStyle)Returns the threshold for using tightening as an alternative to truncation.
public float tighteningFactorForTruncation
()
When the line break mode specifies truncation, the text system attempts to tighten intercharacter spacing as an alternative to truncation, provided that the ratio of the text width to the line fragment width does not exceed 1.0 + the tightening factor returned by this method. Otherwise the text is truncated at a location determined by the line break mode. The default value is 0.05.
setTighteningFactorForTruncation
(NSMutableParagraphStyle)These constants specify what happens when a line is too long for its container:
These constants specify the types of tab stops:
Constant |
Description |
---|---|
|
A left-aligned tab stop. |
|
A right-aligned tab stop. |
|
A center-aligned tab stop. |
|
Aligns columns of numbers by the decimal point. |
These constants specify the writing directions:
Constant | Description |
---|---|
WritingDirectionLeftToRight | The writing direction is left to right. |
WritingDirectionRightToLeft | The writing direction is right to left. |
© 1997, 2007 Apple Inc. All Rights Reserved. (Last updated: 2007-02-01)