Cocoanetics / DTCoreText

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

Underline color #1257

Closed debadaracco closed 1 year ago

debadaracco commented 2 years ago

add underline color. It was implemented in html element

odrobnik commented 2 years ago

Question @debadaracco: You are using NSUnderlineStyleAttributeName for the underline thickness... Is that officially supported by this attribute in UIKit, i.e. UITextView?

debadaracco commented 2 years ago

Question @debadaracco: You are using NSUnderlineStyleAttributeName for the underline thickness... Is that officially supported by this attribute in UIKit, i.e. UITextView?

Hi, I tested using label, I will test with textview. I don’t see any comment in the apple documentation about this

debadaracco commented 2 years ago

Question @debadaracco: You are using NSUnderlineStyleAttributeName for the underline thickness... Is that officially supported by this attribute in UIKit, i.e. UITextView?

Hi, I tested using label, I will test with textview. I don’t see any comment in the apple documentation about this

If you like, I can remove this logic for the pull request. I need this for one project, so I could asking you if exists some way to use this logic as a custom attribute. Thanks so much

debadaracco commented 2 years ago

i removed the thickness code

odrobnik commented 2 years ago

Sorry, I don't understand what you are doing. If you need this attribute, then we can make a custom one. I just don't want to use official attributes in a different way than they are used in UIKit. E.g. the style attribute is just 1 or 0 IIRC.

debadaracco commented 2 years ago

Sorry, I don't understand what you are doing. If you need this attribute, then we can make a custom one. I just don't want to use official attributes in a different way than they are used in UIKit. E.g. the style attribute is just 1 or 0 IIRC.

I have a project that uses DTCoreText. In this project I need to set the the underline‘s thickness and color. I saw that if I set a numeric value for underline style, for example 3, the underline width increases. I did not see this in the apple documentation, so when you wrote the comment i decided to remove this code on the pull request, because it was a wrong implementation of the native property. For the other hand, what do you think about the underline color code? Thanks so much

odrobnik commented 2 years ago

Well, if it works according to your findings then it should stay as a new feature! So you see the underline become 2 pt if you set a value 2?

debadaracco commented 2 years ago

Well, if it works according to your findings then it should stay as a new feature! So you see the underline become 2 pt if you set a value 2?

It doesn’t work. I saw that apple use specific numbers for underline style and there are some middle values that works with a wrong way. This way works for my functionality but is a wrong implementation. For example:

For NSUnderlineStyleThick the value is 2 and for NSUnderlineStyleDouble the value is 9

Between thick and double are 7 numbers. in my case I tested only with 3 and the underline width was increased but now I think it was a bug

odrobnik commented 2 years ago

Do you need for your project to set specific underline widths? Or would it be sufficient to map the HTML value 1 to thin and 2 and more to thick? Here are the available values: https://developer.apple.com/documentation/uikit/nsunderlinestyle

debadaracco commented 2 years ago

Do you need for your project to set specific underline widths? Or would it be sufficient to map the HTML value 1 to thin and 2 and more to thick? Here are the available values: https://developer.apple.com/documentation/uikit/nsunderlinestyle

Hi, I need to set specific underline width but in this moment I need to priorize the underline color.

debadaracco commented 2 years ago

Hi @odrobnik, i am writing you for ask about this pull request, please tell me if I should change anything about this. I remove the underline weight and now it has only the underline color feature. Thanks so much

odrobnik commented 2 years ago

I'll do a quick check tomorrow and then merge it, ok?

debadaracco commented 2 years ago

Thank you :D