@@ -33,13 +33,13 @@ var DEFAULT_BUTTON_ICON_COLOR = 'white';
33
33
var DEFAULT_BUTTON_RADIUS = 5 ;
34
34
var DEFAULT_BUTTON_BACKGROUND = IOS7_BLUE ;
35
35
36
- var TypefaceTextView ;
37
-
38
- if ( Platform . OS === 'android' ) {
39
- TypefaceTextView = require ( './TypefaceTextView' ) ;
40
- }
41
-
42
36
function createIconSet ( glyphMap : Object , fontFamily : string , fontFile : string ) : Function {
37
+ var fontReference = fontFamily ;
38
+ // Android doesn't care about actual fontFamily name, it will only look in fonts folder.
39
+ if ( Platform . OS === 'android' && fontFile ) {
40
+ fontReference = fontFile . replace ( / \. ( o t f | t t f ) $ / , '' ) ;
41
+ }
42
+
43
43
var Icon = React . createClass ( {
44
44
propTypes : {
45
45
name : React . PropTypes . oneOf ( Object . keys ( glyphMap ) ) . isRequired ,
@@ -73,20 +73,8 @@ function createIconSet(glyphMap : Object, fontFamily : string, fontFile : string
73
73
props . style = [ styleDefaults , style ] ;
74
74
props . ref = ( component ) => this . _root = component ;
75
75
76
- // For android we have to use our own subclass of the TextView since it
77
- // doesn't yet support custom fonts
78
- if ( Platform . OS === 'android' ) {
79
- // FIXME: Temporary workaround until I can figure out how to automatically size icons
80
- styleDefaults . width = size ;
81
- styleDefaults . height = size ;
82
- styleDefaults . lineHeight = size ;
83
- if ( TypefaceTextView == null ) {
84
- throw new Error ( "TypefaceTextView component must be available on Android" ) ;
85
- }
86
- return ( < TypefaceTextView { ...props } fontFile = { fontFile } > { glyph } { this . props . children } </ TypefaceTextView > ) ;
87
- }
76
+ styleDefaults . fontFamily = fontReference ;
88
77
89
- styleDefaults . fontFamily = fontFamily ;
90
78
return ( < Text { ...props } > { glyph } { this . props . children } </ Text > ) ;
91
79
}
92
80
} ) ;
0 commit comments