Cocoanetics / DTCoreText

Methods to allow using HTML code with CoreText
BSD 2-Clause "Simplified" License
6.35k stars 1.18k forks source link

需要自定义DTCoreTextParagraphStyle属性 #1283

Open Gaozn opened 2 months ago

Gaozn commented 2 months ago

rt.

vickyleu commented 2 months ago

You need to always ask questions in english, because GitHub is a global comprehensive community, To avoid consuming the maintainer's energy, We should all maintain good asking habits to facilitate more users with questions to find the same questions. you can also consider using my modified DTCoreText, which adds a public interface.

pod 'DTCoreText', :git => "https://github.com/vickyleu/DTCoreText.git"

I use kotlin multiplatform for development, you can change to swift or objective-c according to the open interface

 val stringBuilder = DTHTMLAttributedStringBuilder(
        hTML = data,
        options = options,
        documentAttributes = null
    )
    if(density!=null){
        //  表格处理
        stringBuilder.registerTagHandlers(tagHandlers = TableHandler(maxWidth, density).allHandlers())
        stringBuilder.registerTagHandlers(tagHandlers = listOf(MathHandler(maxWidth, density)))
        stringBuilder.registerTagHandlers(tagHandlers = listOf(Base64ImageHandler(maxWidth, density)))
        stringBuilder.registerTagHandlers(
            tagHandlers = listOf(
                PTagHandler(),
                ATagHandler(maxWidth),
                EmTextBlockHandler()
            )
        )
    }