NSFont+SFProText.swift 1.6 KB

1234567891011121314151617181920212223242526272829303132333435363738394041
  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. @objc static func UbuntuRegularFontWithSize(_ size: CGFloat) -> NSFont {
  31. return NSFont(name: "Ubuntu-Regular", size: max(1, size)) ?? NSFont.systemFont(ofSize: max(1, size))
  32. }
  33. }