NSFont+SFProText.swift 1.4 KB

12345678910111213141516171819202122232425262728293031323334353637
  1. //
  2. // NSFont+SFProText.swift
  3. // PDF Reader Pro
  4. //
  5. // Created by lizhe on 2023/2/8.
  6. //
  7. import Foundation
  8. extension NSFont {
  9. @objc static func SFProTextRegularFont(_ size: CGFloat) -> NSFont {
  10. return NSFont(name: "SFProText-Regular", size: max(1, size)) ?? NSFont.systemFont(ofSize: max(1, size))
  11. }
  12. @objc static func SFProTextSemiboldFont(_ size: CGFloat) -> NSFont {
  13. return NSFont(name: "SFProText-Semibold", size: max(1, size)) ?? NSFont.systemFont(ofSize: max(1, size))
  14. }
  15. @objc static func SFProTextBoldFont(_ size: CGFloat) -> NSFont {
  16. return NSFont(name: "SFProText-Bold", size: max(1, size)) ?? NSFont.systemFont(ofSize: max(1, size))
  17. }
  18. @objc static func SFProTextHeavyFont(_ size: CGFloat) -> NSFont {
  19. return NSFont(name: "SFProText-Heavy", size: max(1, size)) ?? NSFont.systemFont(ofSize: max(1, size))
  20. }
  21. @objc static func SFMediumFontWithSize(_ size: CGFloat) -> NSFont {
  22. return NSFont(name: "SFProText-Medium", size: max(1, size)) ?? NSFont.systemFont(ofSize: max(1, size))
  23. }
  24. @objc static func UbuntuMediumFontWithSize(_ size: CGFloat) -> NSFont {
  25. return NSFont(name: "Ubuntu-Medium", size: max(1, size)) ?? NSFont.systemFont(ofSize: max(1, size))
  26. }
  27. @objc static func UbuntuBoldFontWithSize(_ size: CGFloat) -> NSFont {
  28. return NSFont(name: "Ubuntu-Bold", size: max(1, size)) ?? NSFont.systemFont(ofSize: max(1, size))
  29. }
  30. }