LiYanan2004 / MarkdownView

Rendering Markdown text natively in SwiftUI.
https://liyanan2004.github.io/MarkdownView/documentation/markdownview/
MIT License
193 stars 18 forks source link

Add font group protocol #22

Closed LiYanan2004 closed 1 year ago

LiYanan2004 commented 1 year ago

Add MarkdownFontGroup protocol for better experience when you want to modify multiple types of font.

Deprecation

If you are using MarkdownFontProvider, you should migrate to MarkdownFontGroup.

Example

Define your font group:

struct MyCustomFontGroup: MarkdownFontGroup {
    var h1: Font { Font.largeTitle.weight(.black) }
}
extension MarkdownFontGroup where Self == MyCustomFontGroup {
    static var custom: MyCustomFontGroup { .init() }
}

Attach the font group:

MarkdownView(...)
    .fontGroup(.custom)