Skip to content

Instantly share code, notes, and snippets.

@yccheok
Created November 27, 2023 05:44
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save yccheok/ce0f516626e31ccda36d65552e6ade42 to your computer and use it in GitHub Desktop.
Save yccheok/ce0f516626e31ccda36d65552e6ade42 to your computer and use it in GitHub Desktop.
func getFont(_ textSize: Int) -> UIFont {
switch self {
case .new_york:
let sfFont = UIFont.systemFont(ofSize: CGFloat(textSize))
var fontDescriptor = sfFont.fontDescriptor
fontDescriptor = fontDescriptor.withSymbolicTraits(.traitBold) ?? fontDescriptor
if let newYorkFontDescriptor = fontDescriptor.withDesign(.serif) {
let newYorkFont = UIFont(descriptor: newYorkFontDescriptor, size: 0.0)
return newYorkFont
} else {
return sfFont
}
case .san_francisco:
let sfFont = UIFont.boldSystemFont(ofSize: CGFloat(textSize))
return sfFont
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment