Code example for TextPaint

Methods: getTypeface, setFakeBoldText, setTextSkewX, setTypeface

0
		setSwitchTypefaceByIndex(typefaceIndex, styleIndex);
		appearance.recycle();
	} 
 
	public void setSwitchTypeface(Typeface tf) {
		if (mTextPaint.getTypeface() != tf) {
			mTextPaint.setTypeface(tf);
 
			requestLayout();
			invalidate();
		} 
	} 
 
	public void setSwitchTypeface(Typeface tf, int style) {
		if (style > 0) {
			if (tf == null) {
				tf = Typeface.defaultFromStyle(style);
			} else { 
				tf = Typeface.create(tf, style);
			} 
			setSwitchTypeface(tf);
			int typefaceStyle = tf != null ? tf.getStyle() : 0;
			int need = style & ~typefaceStyle;
			mTextPaint.setFakeBoldText((need & Typeface.BOLD) != 0);
			mTextPaint.setTextSkewX((need & Typeface.ITALIC) != 0 ? -0.25f : 0);
		} else { 
			mTextPaint.setFakeBoldText(false);
			mTextPaint.setTextSkewX(0);
			setSwitchTypeface(tf);
		} 
	} 
 
	private void setSwitchTypefaceByIndex(int typefaceIndex, int styleIndex) {