NSTextField baseline inconsistency

Originator:mayoff
Number:rdar://36672952 Date Originated:19-Jan-2018 05:15 PM
Status:Closed Resolved:
Product:macOS + SDK Product Version:macOS 10.12.6 (16G1114) / Xcode Version 9.2 (9C40b)
Classification:UI/Usability Reproducible:Always
 
Summary:
Dear AppKitterinos,

NSTextField’s baseline is inconsistent/wrong for some border/bezel styles.

Let’s consider the no-border, no-bezel (“bare”) style as the reference. This is sensible because the first baseline offset in this style does in fact line up with the visual baseline of the text.

A bordered text field puts its first baseline at the reference baseline. Yay!

A square-bezeled text field puts its first baseline one point above the reference baseline. Boo!

A round-bezeled text field puts its first baseline one point above the reference baseline. Boo!

I have attached a project to demonstrate the problem. At the bottom of the window, you’ll find one text field for each border/bezel style. These text fields are constrained to have the same first baseline. There is also an orange one-point-tall NSBox whose top is constrained to the first baseline of the bare text field. This orange line makes it easy to see that in the square-bezeled and round-bezeled text fields, the apparent visual baseline of the text is offset from the baselines of the bare and bordered text fields.

Please make text field baselines line up.

Thanks,
Rob


Steps to Reproduce:
1. See attached project.

Expected Results:
Baseline alignment accurate enough to satisfy even the most anal-retentive designer.

Actual Results:
A plague of misaligned baselines.

Version:
macOS 10.12.6 (16G1114) / Xcode Version 9.2 (9C40b)

Notes:

Comments

Apple Developer Relations Oct 22 We’ve made a number of changes in this area in 10.14 as all AppKit controls are now using NSTypesetterBehavior_10_4 by default. For compatibility purposes, the baselines of controls using the previous default setting, NSTypesetterBehavior_10_2_WithCompatibility, will not change.

Additionally, it’s not really expected that the visual baseline of all text field configurations are in the same place:

  • Bezeled NSTextFields are using specific artwork and the baseline will be visually aligned within the boundaries of the bezel artwork. This may not be the same as the “raw” baseline value as determined by the text measurement.
  • Bordered NSTextFields have historically had a different baseline. In 10.14, stock bordered NSTextFields will have baselines that are visually aligned with square bezeled NSTextFields, but subclasses of NSTextField will continue to use the historical baseline for compatibility purposes.
  • Un-bezeled and un-bordered NSTextFields have no visual boundaries and will use the “raw” baseline value as determined by the text measurement.

Please note: Reports posted here will not necessarily be seen by Apple. All problems should be submitted at bugreport.apple.com before they are posted here. Please only post information for Radars that you have filed yourself, and please do not include Apple confidential information in your posts. Thank you!