Skip to content

Instantly share code, notes, and snippets.

@iSapozhnik
Created December 20, 2021 21:39
Show Gist options
  • Save iSapozhnik/56260c43b2e56951b9cd12d712eb04cb to your computer and use it in GitHub Desktop.
Save iSapozhnik/56260c43b2e56951b9cd12d712eb04cb to your computer and use it in GitHub Desktop.
Rounded NSFont
extension NSFont {
class func roundedFont(ofSize size: CGFloat, weight: NSFont.Weight) -> NSFont {
let systemFont = NSFont.systemFont(ofSize: size, weight: weight)
guard let descriptor = systemFont.fontDescriptor.withDesign(.rounded),
let roundedFont = NSFont(descriptor: descriptor, size: size) else {
return systemFont
}
return roundedFont
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment