MessageKit / MessageKit

A community-driven replacement for JSQMessagesViewController
https://messagekit.github.io
MIT License
6.04k stars 1.18k forks source link

Custom Font: message is not displayed completely when using custom font for long messages #639

Closed qaisershehzad closed 6 years ago

qaisershehzad commented 6 years ago

General Information

What happened?

In Message Cell Attributed text is truncated not completely loading for long messages. Attached reference screenshot from Chat Example. customfont

What did you expect to happen?

It should load complete message like loading for system fonts.

SD10 commented 6 years ago

@qaisershehzad What is the size of your message in characters?

qaisershehzad commented 6 years ago

I tried on multiple strings of different lengths. Above screenshot String length is "1614"

Length: "348" smallstring

Length: "182" 182

SD10 commented 6 years ago

@qaisershehzad Show me the code where you create the message, please

qaisershehzad commented 6 years ago

thanks for your quick response.

I forked and pushed code with custom font. I am changing font here https://github.com/qaisershehzad/MessageKit/blob/master/Example/Sources/SampleData.swift#L85-L86. If you uncomment line 86 and comment line 85 then it start truncating text. like below screemshot

customfont_colfax

But if you comment line 86 systemfont

In my findings the height returned by https://github.com/qaisershehzad/MessageKit/blob/master/Sources/Extensions/NSAttributedString%2BExtensions.swift#L33 is incorrect for custom fonts.

SD10 commented 6 years ago

Thanks for following up @qaisershehzad. I'm not sure how to handle this one because I'm relying on Foundation to size attributed strings properly. I'm going to say it's lower priority right now considering this is regarding a custom font. If you are willing to dig deeper on this one please let us know what you find

zhongwuzw commented 6 years ago

I will investigate this a while later.

qaisershehzad commented 6 years ago

I investigated this a bit.

Actually the height returned by extension is fine for custom font as well I tried on other sample project. When we give same width it return same height in other sample project and AttributedText is also completely shown on UILabel. https://github.com/qaisershehzad/MessageKit/blob/master/Sources/Extensions/NSAttributedString%2BExtensions.swift#L33

Further I tried to disable message styling in ChatExample and a new Label is added in textMessageCell of same frame like MessageLabel here https://github.com/qaisershehzad/MessageKit/blob/master/Sources/Views/Cells/TextMessageCell.swift#L79-L103 So on this label text is fine as below screenshot. newlabel

So it seems issue is with MessageLabel configurations (text insets and framing of messageContainerView and styling).

zhongwuzw commented 6 years ago

@qaisershehzad , fixed in #645 .