Fix negative letterspacing in Fabric android

Summary:
This diff adds support for negative letterspacing values in Fabric android
Changelog: add support fot negative letterspacing values in Fabric android

Reviewed By: JoshuaGross

Differential Revision: D18054648

fbshipit-source-id: de1b906e6b8c0b021ffdc2e4bdad243075230667
This commit is contained in:
David Vacca 2019-10-22 10:16:42 -07:00 коммит произвёл Facebook Github Bot
Родитель 10f55e752d
Коммит 7935174d48
2 изменённых файлов: 10 добавлений и 4 удалений

Просмотреть файл

@ -35,7 +35,6 @@ public class TextAttributeProps {
private static final int DEFAULT_TEXT_SHADOW_COLOR = 0x55000000;
protected float mLineHeight = Float.NaN;
protected float mLetterSpacing = Float.NaN;
protected boolean mIsColorSet = false;
protected boolean mAllowFontScaling = true;
protected int mColor;
@ -197,10 +196,17 @@ public class TextAttributeProps {
public void setLetterSpacing(float letterSpacing) {
mLetterSpacingInput = letterSpacing;
mLetterSpacing =
}
public float getLetterSpacing() {
float letterSpacingPixels =
mAllowFontScaling
? PixelUtil.toPixelFromSP(mLetterSpacingInput)
: PixelUtil.toPixelFromDIP(mLetterSpacingInput);
// `letterSpacingPixels` and `mFontSize` are both in pixels,
// yielding an accurate em value.
return letterSpacingPixels / mFontSize;
}
public void setAllowFontScaling(boolean allowFontScaling) {

Просмотреть файл

@ -74,10 +74,10 @@ public class TextLayoutManager {
start, end, new ReactBackgroundColorSpan(textAttributes.mBackgroundColor)));
}
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) {
if (!Float.isNaN(textAttributes.mLetterSpacing)) {
if (!Float.isNaN(textAttributes.getLetterSpacing())) {
ops.add(
new SetSpanOperation(
start, end, new CustomLetterSpacingSpan(textAttributes.mLetterSpacing)));
start, end, new CustomLetterSpacingSpan(textAttributes.getLetterSpacing())));
}
}
ops.add(