Skip to content

Commit

Permalink
Merge pull request #34 from rolandkakonyi/master
Browse files Browse the repository at this point in the history
Fix issue caused when font size calculated with long decimals
  • Loading branch information
tbaranes authored Oct 25, 2018
2 parents b9f8012 + fe126d7 commit a9ceff8
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 2 deletions.
2 changes: 1 addition & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ N/A

#### Bugfixes

N/A
- Fix rounding when calculated font size has long decimals therefore rendering results with cutting off the last line (probably due to rounding up in UILabel rendering)

## [3.0.0](https://github.com/tbaranes/FittableFontLabel/releases/tag/3.0.0) (18-09-2018)

Expand Down
3 changes: 2 additions & 1 deletion Source/UILabelExtension.swift
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,8 @@ public extension UILabel {
let constraintSize = numberOfLines == 1 ?
CGSize(width: CGFloat.greatestFiniteMagnitude, height: rectSize.height) :
CGSize(width: rectSize.width, height: CGFloat.greatestFiniteMagnitude)
return binarySearch(string: string, minSize: minimumFontSize, maxSize: maxFontSize, size: rectSize, constraintSize: constraintSize)
let calculatedFontSize = binarySearch(string: string, minSize: minimumFontSize, maxSize: maxFontSize, size: rectSize, constraintSize: constraintSize)
return (calculatedFontSize * 10.0).rounded(.down) / 10.0
}

}
Expand Down

0 comments on commit a9ceff8

Please sign in to comment.