Fix TextInput placeholder font when using custom fonts. Fixes #4600

Summary:
When using a TextInput with a custom font, the placeholder didn't use that font. This is because ReactTextInputManager didn't use ReactFontManager to create the TypeFace which handles custom fonts.

**Test plan**
Tested in UI explorer by reproducing the bug with and testing that the custom font gets applied properly after the fix.
``` js
<TextInput
  placeholder="Hello"
  style={{ fontFamily: 'notoserif' }}
/>
```
Closes https://github.com/facebook/react-native/pull/12000

Reviewed By: hramos

Differential Revision: D4443713

fbshipit-source-id: e92c9822d9226681d7b00126dad95e5534c0c46e
This commit is contained in:
Janic Duplessis
2017-01-24 11:14:27 -08:00
committed by Facebook Github Bot
parent a116dbf4a4
commit 1100c40cb8

View File

@@ -49,6 +49,7 @@ import com.facebook.react.uimanager.annotations.ReactPropGroup;
import com.facebook.react.uimanager.events.EventDispatcher;
import com.facebook.react.views.imagehelper.ResourceDrawableIdHelper;
import com.facebook.react.views.text.DefaultStyleValuesUtil;
import com.facebook.react.views.text.ReactFontManager;
import com.facebook.react.views.text.ReactTextUpdate;
import com.facebook.react.views.text.ReactTextView;
import com.facebook.react.views.text.TextInlineImageSpan;
@@ -190,7 +191,10 @@ public class ReactTextInputManager extends BaseViewManager<ReactEditText, Layout
if (view.getTypeface() != null) {
style = view.getTypeface().getStyle();
}
Typeface newTypeface = Typeface.create(fontFamily, style);
Typeface newTypeface = ReactFontManager.getInstance().getTypeface(
fontFamily,
style,
view.getContext().getAssets());
view.setTypeface(newTypeface);
}