Skip to content

jiachenyee/Font

Repository files navigation

Font

Easily use custom fonts within Swift Playgrounds projects!

image

Adding the Package

  1. Add a new Swift Package into the Swift Playgrounds project
  2. Paste in https://github.com/jiachenyee/Font as the Package URL.
  3. Select Add to Package

Implement font

Fonts without any weights

Text("Hello!")
    .font(.custom(.myFontName))

Fonts with weights

Regular/Default weight

Text("Hello!")
    .font(.custom(.myFontName()))

Other weights

Text("Hello!")
    .font(.custom(.myFontName(weight: .bold)))

Font customization

Default implementation

Text("Hello!")
    .font(.custom(.myFontName))

Custom font size

Text("Hello!")
    .font(.custom(.myFontName, size: 100))

[iOS 14] Relative fonts

Set font size relative to another font type using Apple's relativeTo: font sizes.

Text("Hello!")
    .font(.custom(.myFontName, size: 100, relativeTo: .title))