Skip to content

Commit

Permalink
lineSpacingAdd should not be negative, so I add a constraint.
Browse files Browse the repository at this point in the history
  • Loading branch information
eneim committed Jul 18, 2016
1 parent 4860396 commit 3f16925
Showing 1 changed file with 2 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -235,7 +235,8 @@ private void recalculate(int width) {
int fontHeight = Math.abs(fm.ascent - fm.descent) + fm.leading;
final int baselineAlignedLineHeight =
(int) (fourDip * (float) Math.ceil(lineHeightHint / fourDip));
final int lineSpacingAdd = baselineAlignedLineHeight - fontHeight;
// Addition line spacing to match desired line height. Should be non-negative.
final int lineSpacingAdd = Math.max(0, baselineAlignedLineHeight - fontHeight);

// now create the layout with our desired insets & line height
createLayout(width, lineSpacingAdd);
Expand Down

0 comments on commit 3f16925

Please sign in to comment.