Skip to content

Instantly share code, notes, and snippets.

@iSapozhnik
Created December 20, 2021 21:39
Show Gist options
  • Select an option

  • Save iSapozhnik/56260c43b2e56951b9cd12d712eb04cb to your computer and use it in GitHub Desktop.

Select an option

Save iSapozhnik/56260c43b2e56951b9cd12d712eb04cb to your computer and use it in GitHub Desktop.

Revisions

  1. iSapozhnik created this gist Dec 20, 2021.
    11 changes: 11 additions & 0 deletions NSFont+Extensions.swift
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,11 @@
    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
    }
    }