Reputation: 27397
The text inside NSTextField
gets cut off when I have the font changed to monospacedDigitSystemFont
.
I have the following code in the viewDidLoad
method. I do not understand why it has been cut off since sizeToFit
has been called and the intrinsic size should be used.
The label at the bottom looks fine and it is using the default system font.
labelTimeNow.sizeToFit()
labelTimeNow.font = NSFont.monospacedDigitSystemFont(
ofSize: labelTimeNow.font!.pointSize,
weight: .medium
)
labelTimeNow.stringValue = DCClock.getCurrentTimeInFormat("HH:mm")
Reference
Upvotes: 1
Views: 246
Reputation: 27397
Stupid me, I should call sizeToFit
after changing the font spacing.
labelTimeNow.font = NSFont.monospacedDigitSystemFont(
ofSize: labelTimeNow.font!.pointSize,
weight: .medium
)
labelTimeNow.stringValue = DCClock.getCurrentTimeInFormat("HH:mm")
labelTimeNow.sizeToFit()
Upvotes: 1