NuPlay / RichText

Easily show RichText(html) in SwiftUI
MIT License
209 stars 36 forks source link

Font doesn't work #40

Closed sageibra closed 5 months ago

sageibra commented 11 months ago

Hi, when I add new font using fontType modifier nothing changes.

pvtan commented 8 months ago

As a workaround, you can insert this custom CSS instead for your preferred font for it will be loaded into the RichText's webview (just replace usage of Lobster with your preferred font):

RichText(html: <html_text_here>)
  .fontType(.custom(UIFont.lobster)) // reference the UIFont
  .customCSS("""
      @font-face {
          font-family: 'LobsterTwo-Regular';
          src: url("LobsterTwo-Regular.ttf") format('truetype'); // name of your font in Info.plist
      }
      body {
          font-family: 'LobsterTwo-Regular';
      }
  """)