Global Variable

NSWritingDirectionAttributeName

Declaration

iOS, Mac Catalyst, tvOS, watchOS
const NSAttributedStringKey NSWritingDirectionAttributeName;
macOS
NSAttributedStringKey NSWritingDirectionAttributeName;

Discussion

The value of this attribute is an NSArray object containing NSNumber objects representing the nested levels of writing direction overrides, in order from outermost to innermost.

This attribute provides a means to override the default bidirectional text algorithm, equivalent to using the Unicode bidi control characters LRE, RLE, LRO, or RLO paired with PDF, but as a higher-level attribute. (See Unicode Standard Annex #9 for information about the Unicode bidi formatting codes.) The NSWritingDirectionAttributeName constant is a character-level attribute that provides a higher-level alternative to the inclusion of explicit bidirectional control characters in text. It is the NSAttributedString equivalent of the HTML markup using bdo element with the dir attribute.

The values of the NSNumber objects should be 0, 1, 2, or 3, for LRE, RLE, LRO, or RLO respectively, and combinations of NSWritingDirectionLeftToRight and NSWritingDirectionRightToLeft with NSTextWritingDirectionEmbedding or NSTextWritingDirectionOverride, as shown in Table 1.

Table 1

Values of NSWritingDirectionAttributeName and equivalent markup

Array NSNumber Values

Unicode Control Characters

Writing Direction Constants

0

LRE

NSWritingDirectionLeftToRight | NSTextWritingDirectionEmbedding

1

RLE

NSWritingDirectionRightToLeft | NSTextWritingDirectionEmbedding

2

LRO

NSWritingDirectionLeftToRight | NSTextWritingDirectionOverride

3

RLO

NSWritingDirectionRightToLeft | NSTextWritingDirectionOverride

See Also

Keys

NSAccessibilityAutocorrectedTextAttribute

Autocorrected text (NSNumber as a Boolean value).

NSAccessibilityBackgroundColorTextAttribute

Text background color (CGColorRef).

NSAccessibilityFontTextAttribute

Font keys (NSDictionary).

NSAccessibilityForegroundColorTextAttribute

Text foreground color (CGColorRef).

NSAccessibilityMarkedMisspelledTextAttribute

Misspelled text that is visibly marked as misspelled (NSNumber as a Boolean value). If you’re implementing a custom text-editing app, use NSAccessibilityMarkedMisspelledTextAttribute to ensure that VoiceOver properly identifies misspelled text to users.

NSAccessibilityMisspelledTextAttribute

Misspelled text that isn’t necessarily visibly marked as misspelled (NSNumber as a Boolean value). Beginning in macOS 10.9, VoiceOver no longer checks for this attribute; instead, VoiceOver uses NSAccessibilityMarkedMisspelledTextAttribute.

NSAccessibilityShadowTextAttribute

Text shadow (NSNumber as a Boolean value).

NSAccessibilityStrikethroughTextAttribute

Text strikethrough (NSNumber as a Boolean value).

NSAccessibilityStrikethroughColorTextAttribute

Text strikethrough color (CGColorRef).

NSAccessibilitySuperscriptTextAttribute

Text superscript style (NSNumber). Values > 0 are superscript; values < 0 are subscript.

NSAccessibilityUnderlineTextAttribute

Text underline style (NSNumber).

NSAccessibilityUnderlineColorTextAttribute

Text underline color (CGColorRef).

NSBaselineOffsetAttributeName

Vertical offset for text position.

NSCharacterShapeAttributeName

An integer value. The value is interpreted as Apple Type Services kCharacterShapeType selector + 1.

Deprecated
NSCursorAttributeName

The value of this attribute is an NSCursor object. The default value is the cursor returned by the IBeamCursor method

NSGlyphInfoAttributeName

The name of an NSGlyphInfo object.

NSSpellingStateAttributeName

The spelling state attribute.

NSSuperscriptAttributeName

The value of this attribute is an NSNumber object containing an integer. The default value is 0.

NSToolTipAttributeName

The value of this attribute is an NSString object containing the tooltip text. The default value is nil, indicating no tooltip is available.

NSUsesScreenFontsDocumentAttribute

The value of this attribute is an NSNumber object containing a Boolean; this attribute corresponds to the usesScreenFonts method of NSLayoutManager; if absent, follows the system default setting

Deprecated