Closed jfclifton closed 1 year ago
Thanks for letting me know!
As a result of finding out why happened that issue
I found that I need to change the baseURL of "webView.loadHTMLString"
I will fix that part and add the description of using custom fonts. (probably within 2 days)
I fixed that bug! But now that I think about it, the font part seems to need more explanation. I'll add that later
You could use it like this (Of course, before that, you need to add font to "info.plist" just like you would use a custom font anywhere else)
import SwiftUI
import RichText
struct RichText_Test: View {
@State private var html = ""
var body: some View {
ScrollView{
RichText(html: html)
.fontType(.customName("Noto Sans"))
.customCSS("""
@font-face {
font-family: 'Noto Sans';
src: url("NotoSans-Regular.ttf") format('truetype');
}
""")
}
}
}
struct RichText_Test_Previews: PreviewProvider {
static var previews: some View {
RichText_Test()
}
}
Cool thank you for addressing this!
I'm trying to get a custom font rendering in my webview. I feel like I'm doing all the right steps but I'm unable to see a font change. I tried using the FontType.custom with a name and a UIFont. The UIFont was definitely not nil and was the correct font I wanted passed in. Should using this modifier be the only thing I need? I also tried using custom CSS to change the font. Nothing worked though. Does someone have an example using a custom font just so I could compare. For more project context I added this library as a local package because of needing a few small changes to styling. The custom fonts are added to the main target of the project. Do they need to be added as resources to local package?
Thanks for the library - it's very nice