Skip to content

Commit

Permalink
Merge pull request badoo#122 from AntonPalich/Fix_text_size_calculation
Browse files Browse the repository at this point in the history
Fixed text size calculation
  • Loading branch information
AntonPalich committed May 5, 2016
2 parents acc9900 + 5a9c096 commit 06655cd
Showing 1 changed file with 8 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -234,11 +234,14 @@ private final class TextBubbleLayoutModel {
}

private func textSizeThatFitsWidth(width: CGFloat) -> CGSize {
return self.layoutContext.text.boundingRectWithSize(
CGSize(width: width, height: CGFloat.max),
options: [.UsesLineFragmentOrigin, .UsesFontLeading],
attributes: [NSFontAttributeName: self.layoutContext.font], context: nil
).size.bma_round()
let maxSize = CGSize(width: width, height: CGFloat.max)
let options: NSStringDrawingOptions = [.UsesLineFragmentOrigin, .UsesFontLeading]
let attributes = [NSFontAttributeName: self.layoutContext.font]
var size = self.layoutContext.text.boundingRectWithSize(maxSize, options: options, attributes: attributes, context: nil).size.bma_round()
// Added to prevent: https://github.com/badoo/Chatto/issues/121
size.width += 1
size.height += 1
return size
}
}

Expand Down

0 comments on commit 06655cd

Please sign in to comment.