Skip to content

NSTextAlignment NSRightTextAlignment and NSCenterTextAlignment have different values from AppKit #752

Description

@DTW-Thalion

The NSTextAlignment constants in AppKit/NSText.h are ordered:

NSLeftTextAlignment      = 0
NSRightTextAlignment     = 1
NSCenterTextAlignment    = 2
NSJustifiedTextAlignment = 3
NSNaturalTextAlignment   = 4

AppKit uses NSTextAlignmentRight = 2 and NSTextAlignmentCenter = 1, i.e. Right and Center are swapped relative to GNUstep (Left, Justified and Natural agree).

Code that uses the symbolic names round-trips correctly, but the raw integer stored differs (for example -[NSText setAlignment: NSRightTextAlignment] yields 1 on GNUstep and 2 on AppKit). This affects keyed archives written by one and read by the other, and any code comparing raw alignment values.

Aligning the values with AppKit would be an ABI change (archives, and any code relying on the current numbers), so I have not sent a patch. Filing to check whether the project wants to align these (and, relatedly, NSFloatingWindowLevel which is 2 vs AppKit 3, and NSTabViewControllerTabStyleUnspecified which is 3 vs AppKit -1). @fredkiefer ?

Found while adding NSText/paragraph-alignment tests.

Metadata

Metadata

Labels

No labels
No labels

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions