Code example for TextPaint

Methods: getTypeface, setFakeBoldText, setTextSkewX, setTypeface

0
            final int typefaceStyle = tf != null ? tf.getStyle() : 0;
            final 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);
        } 
    } 
 
    /** 
     * Sets the typeface in which the text should be displayed on the switch. 
     * Note that not all Typeface families actually have bold and italic 
     * variants, so you may need to use {@link #setSwitchTypeface(Typeface, int)} to get the appearance 
     * that you actually want. 
     *  
     * @attr ref android.R.styleable#TextView_typeface 
     * @attr ref android.R.styleable#TextView_textStyle 
     */ 
    public void setSwitchTypeface(Typeface tf) {
        if (mTextPaint.getTypeface() != tf) {
            mTextPaint.setTypeface(tf);
 
            requestLayout();
            invalidate();
        } 
    }