package com.sabirjan.DrawUyghurWord;

import android.content.Context;
import android.graphics.Canvas;
import android.graphics.Color;
import android.graphics.Paint;
import android.graphics.Typeface;
import android.graphics.Paint.Align;
import android.util.AttributeSet;
import android.widget.TextView;

public class MyTextView extends TextView{

	Paint p;
	Context con;
	String _text="";
	public MyTextView(Context context, AttributeSet attrs, int defStyle) {
		super(context, attrs, defStyle);
		// TODO Auto-generated constructor stub
		con=context;
		init();
	}

	public MyTextView(Context context, AttributeSet attrs) {
		super(context, attrs);
		// TODO Auto-generated constructor stub
		con=context;
		init();
	}

	public MyTextView(Context context) {
		super(context);
		con=context;	
		init();// TODO Auto-generated constructor stub
	}

	private void init()
	{
		p=new Paint();
		Typeface face=Typeface.createFromAsset(con.getAssets(),"fonts/UKIJTuT.ttf");//
		p.setTypeface(face);
		p.setTextAlign(Align.LEFT);
		p.setColor(Color.WHITE);
	}
	@Override
	protected void onDraw(Canvas canvas) {
		// TODO Auto-generated method stub
		p.setTextSize(16);
		canvas.drawText(_text,0,18,p);
		super.onDraw(canvas);
	}

	@Override
	public void setText(CharSequence text, BufferType type) 
	{
		// TODO Auto-generated method stub
		_text=text.toString();
		text=EmptyString(text.length());
		super.setText(text, type);
	}
	private String EmptyString(int len)
	{
		String str="";
		for(int i=0;i<len;i++)
		{
			str+=" ";
		}
		return str;
	}
}
