From b301dba4ba34d2cdddb316cf7387bedc19c7f118 Mon Sep 17 00:00:00 2001 From: Michael Kirk Date: Fri, 6 Jul 2018 12:11:40 -0600 Subject: [PATCH] cell height to spec --- SignalMessaging/utils/ConversationStyle.swift | 15 ++++++++++++--- 1 file changed, 12 insertions(+), 3 deletions(-) diff --git a/SignalMessaging/utils/ConversationStyle.swift b/SignalMessaging/utils/ConversationStyle.swift index 4f534d501d..03d69ba32c 100644 --- a/SignalMessaging/utils/ConversationStyle.swift +++ b/SignalMessaging/utils/ConversationStyle.swift @@ -97,16 +97,25 @@ public class ConversationStyle: NSObject { maxMessageWidth = floor(contentWidth - 48) let messageTextFont = UIFont.ows_dynamicTypeBody + + let baseFontOffset: CGFloat = 11 + // Don't include the distance from the "cap height" to the top of the UILabel // in the top margin. - textInsetTop = max(0, 12 - (messageTextFont.ascender - messageTextFont.capHeight)) + textInsetTop = max(0, round(baseFontOffset - (messageTextFont.ascender - messageTextFont.capHeight))) // Don't include the distance from the "baseline" to the bottom of the UILabel // (e.g. the descender) in the top margin. Note that UIFont.descender is a // negative value. - textInsetBottom = max(0, 12 - abs(messageTextFont.descender)) + textInsetBottom = max(0, round(baseFontOffset - abs(messageTextFont.descender))) + + if _isDebugAssertConfiguration(), UIFont.ows_dynamicTypeBody.pointSize == 17 { + assert(textInsetTop == 7) + assert(textInsetBottom == 7) + } + textInsetHorizontal = 12 - lastTextLineAxis = CGFloat(round(12 + messageTextFont.capHeight * 0.5)) + lastTextLineAxis = CGFloat(round(baseFontOffset + messageTextFont.capHeight * 0.5)) self.primaryColor = ConversationStyle.primaryColor(thread: thread) }