File tree Expand file tree Collapse file tree 2 files changed +15
-9
lines changed Expand file tree Collapse file tree 2 files changed +15
-9
lines changed Original file line number Diff line number Diff line change @@ -54,18 +54,16 @@ - (CGSize)messageBubbleSizeForMessageData:(id<JSQMessageData>)messageData
5454 return [self messageBubbleSizeForCallData: messageData atIndexPath: indexPath withLayout: layout];
5555 }
5656
57- CGSize size;
5857 // BEGIN HACK iOS10EmojiBug see: https://github.com/WhisperSystems/Signal-iOS/issues/1368
5958 if ([self shouldApplyiOS10EmojiFixToString: messageData.text font: layout.messageBubbleFont]) {
60- size = [self withiOS10EmojiFixSuperMessageBubbleSizeForMessageData: messageData
59+ return [self withiOS10EmojiFixSuperMessageBubbleSizeForMessageData: messageData
6160 atIndexPath: indexPath
6261 withLayout: layout];
6362 } else {
64- size = [super messageBubbleSizeForMessageData: messageData atIndexPath: indexPath withLayout: layout];
65- }
66- // END HACK iOS10EmojiBug see: https://github.com/WhisperSystems/Signal-iOS/issues/1368
63+ // END HACK iOS10EmojiBug see: https://github.com/WhisperSystems/Signal-iOS/issues/1368
6764
68- return CGSizeMake (size.width , size.height );
65+ return [super messageBubbleSizeForMessageData: messageData atIndexPath: indexPath withLayout: layout];
66+ }
6967}
7068
7169/* *
@@ -122,7 +120,8 @@ - (CGSize)withiOS10EmojiFixSuperMessageBubbleSizeForMessageData:(id<JSQMessageDa
122120 int lines = (int )floor (superSize.height / emojiFont.lineHeight );
123121
124122 // Add an extra pixel per line to fit the emoji.
125- return CGSizeMake (superSize.width , superSize.height + lines);
123+ // This is a crappy solution. Long messages with only one line of emoji will have an extra pixel per line.
124+ return CGSizeMake (superSize.width , superSize.height + 1.5 * lines);
126125}
127126
128127
Original file line number Diff line number Diff line change @@ -90,14 +90,21 @@ class MesssagesBubblesSizeCalculatorTest: XCTestCase {
9090 let messageData = FakeMessageData ( text: " Wunderschönen Guten Morgaaaahhhn 😝 - hast du gut geschlafen ☺️😘 " )
9191 let actual = calculator. messageBubbleSize ( for: messageData, at: indexPath, with: layout)
9292
93- XCTAssertEqual ( 84 , actual. height) ;
93+ XCTAssertEqual ( 85.5 , actual. height) ;
94+ }
95+
96+ func testHeightForiOS10EmojiBug2( ) {
97+ let messageData = FakeMessageData ( text: " Test test test test test test test test test test test test 😊❤️❤️ " )
98+ let actual = calculator. messageBubbleSize ( for: messageData, at: indexPath, with: layout)
99+
100+ XCTAssertEqual ( 62 , actual. height) ;
94101 }
95102
96103 func testHeightForChineseWithEmojiBug( ) {
97104 let messageData = FakeMessageData ( text: " 一二三四五六七八九十甲乙丙😝戊己庚辛壬圭咖啡牛奶餅乾水果蛋糕 " )
98105 let actual = calculator. messageBubbleSize ( for: messageData, at: indexPath, with: layout)
99106 // erroneously seeing 69 with the emoji fix in place.
100- XCTAssertEqual ( 84 , actual. height) ;
107+ XCTAssertEqual ( 85.5 , actual. height) ;
101108 }
102109
103110 func testHeightForChineseWithoutEmojiBug( ) {
You can’t perform that action at this time.
0 commit comments