danielsaidi / RichTextKit

RichTextKit is a Swift SDK that helps you use rich text in Swift and SwiftUI.
MIT License
950 stars 126 forks source link

Font size change when use setAttributedString() #84

Closed minhtien1403 closed 9 months ago

minhtien1403 commented 1 year ago

I have a string have multi font size, I'm use context.attributedString to get the string then I use context.setAttributedString(), the font size of text now change. Do you have any solution to keep the font size Here is my code func get() { temp = context.attributedString } func set() { context.setAttributedString(to: temp) } | | | P/s: I found that I can fix this problem by remove mutable.setFontSize(to: fontSize) from this function

func setAttributedString(to string: NSAttributedString) {
        let mutable = NSMutableAttributedString(attributedString: string)
        mutable.setFontSize(to: fontSize)
        shouldSetAttributedString = mutable
    }
danielsaidi commented 9 months ago

Hi @minhtien1403

We have improved the font size handling in the upcoming 0.9.9. You can take a look at the main branch and see if it works better there.