Could the problem be in the approximation when using fractional font size ?
Did you try using
func size(withAttributes attrs: [NSAttributedString.Key : Any]? = nil) -> CGSize
and adapt the size to fit window width ?
Some more details here: https://stackoverflow.com/questions/1324379/how-to-calculate-the-width-of-a-text-string-of-a-specific-font-and-font-size
Topic:
UI Frameworks
SubTopic:
AppKit
Tags: