FileDocCategorySizeDatePackage
TypefaceSpan.javaAPI DocAndroid 1.5 API2478Wed May 06 22:41:56 BST 2009android.text.style

TypefaceSpan

public class TypefaceSpan extends MetricAffectingSpan implements android.text.ParcelableSpan
Changes the typeface family of the text to which the span is attached.

Fields Summary
private final String
mFamily
Constructors Summary
public TypefaceSpan(String family)

param
family The font family for this typeface. Examples include "monospace", "serif", and "sans-serif".

        mFamily = family;
    
public TypefaceSpan(android.os.Parcel src)

        mFamily = src.readString();
    
Methods Summary
private static voidapply(android.graphics.Paint paint, java.lang.String family)

        int oldStyle;

        Typeface old = paint.getTypeface();
        if (old == null) {
            oldStyle = 0;
        } else {
            oldStyle = old.getStyle();
        }

        Typeface tf = Typeface.create(family, oldStyle);
        int fake = oldStyle & ~tf.getStyle();

        if ((fake & Typeface.BOLD) != 0) {
            paint.setFakeBoldText(true);
        }

        if ((fake & Typeface.ITALIC) != 0) {
            paint.setTextSkewX(-0.25f);
        }

        paint.setTypeface(tf);
    
public intdescribeContents()

        return 0;
    
public java.lang.StringgetFamily()
Returns the font family name.

        return mFamily;
    
public intgetSpanTypeId()

        return TextUtils.TYPEFACE_SPAN;
    
public voidupdateDrawState(android.text.TextPaint ds)

        apply(ds, mFamily);
    
public voidupdateMeasureState(android.text.TextPaint paint)

        apply(paint, mFamily);
    
public voidwriteToParcel(android.os.Parcel dest, int flags)

        dest.writeString(mFamily);