Font Custom - Android Graphics

Android examples for Graphics:Font

Description

Font Custom

Demo Code


//package com.java2s;
import android.content.Context;
import android.graphics.Paint;
import android.graphics.Typeface;

public class Main {
    public static Paint FontCustom(Context context, int size, int color,
            String path) {//from w  w w  .jav a2s  .  c o  m
        Paint textPaint = new Paint(Paint.ANTI_ALIAS_FLAG);
        textPaint.setTextSize(size);
        textPaint.setColor(color);
        Typeface mFace = Typeface
                .createFromAsset(context.getAssets(), path);
        textPaint.setTypeface(mFace);
        textPaint.setTextAlign(Paint.Align.CENTER);
        textPaint.setAntiAlias(true);
        return textPaint;
    }
}

Related Tutorials