Report error if font size value is zero or negative

Summary:
Text font size should not be negative, this diff throws an exception if TextView uses negative of zero font size

Changelog: [[internal]]

Reviewed By: shergin

Differential Revision: D18068071

fbshipit-source-id: 4074dca2019b6223eef68a407570258adbceaa43
This commit is contained in:
David Vacca
2019-10-22 18:07:00 -07:00
committed by Facebook Github Bot
parent 002d3c179d
commit d9f7f99d91
@@ -204,6 +204,10 @@ public class TextAttributeProps {
? PixelUtil.toPixelFromSP(mLetterSpacingInput)
: PixelUtil.toPixelFromDIP(mLetterSpacingInput);
if (mFontSize <= 0) {
throw new IllegalArgumentException(
"FontSize should be a positive value. Current value: " + mFontSize);
}
// `letterSpacingPixels` and `mFontSize` are both in pixels,
// yielding an accurate em value.
return letterSpacingPixels / mFontSize;