private void setCustomTypeface ( Context context , AttributeSet attrs ) { DEFAULT_TYPEFACE = TypefaceType . getDefaultTypeface ( context ) ; //Typeface.createFromAsset doesn't work in the layout editor. Skipping... if ( isInEditMode ( ) || attrs == null || Build . VERSION . SDK_INT < Build . VERSION_CODES . HONEYCOMB ) { return ; } TypedArray styledAttrs = context . obtainStyledAttributes ( attrs , R . styleable . TypefaceView ) ; Integer fontInt = styledAttrs . getInt ( R . styleable . TypefaceView_tv_typeface , DEFAULT_TYPEFACE ) ; styledAttrs . recycle ( ) ; mCurrentTypeface = TypefaceType . getTypeface ( fontInt ) ; Typeface typeface = getFont ( context , mCurrentTypeface . getAssetFileName ( ) ) ; setTypeface ( typeface ) ; }
Sets the typeface for the view