customise Text

আগের পোস্টটি এখবার দখে আসলে বঝতে সুবিধা হবে।
এবার আমরা custom text লেখা দেখব । কিভাবে custom font ব্যাবহার করা যায়। দেখব কিভাবে chess এর symbol text হিসেবে ব্যাবহার করা যায় ।প্রথমে আমরা এখান থেকে ডাউন লোড করে নিই ।তার পর নিচের মত কোড লেখি —- after downloading the font we have to paste it onto asset folder then it ok .

When you type a: You get a:
Q A black queen on a white square
q A white queen on a white square
W A black queen on a black square
w A white queen on a black square
R A black rook on a white square
r A white rook on a white square
T A black rook on a black square
t A white rook on a black square
N A black knight on a white square
n A white knight on a white square
M A black knight on a black square
m A white knight on a black square
B A black bishop on a white square
b A white bishop on a white square
V A black bishop on a black square
v A white bishop on a black square
K A black king on a white square
k A white king on a white square
L A black king on a black square
l A white king on a black square
P A black pawn on a white square
p A white pawn on a white square
O A black pawn on a black square
o A white pawn on a black square
/ An empty black square
A space An empty white square
1 An upper border side
2 An right border side
3 An left border side
4 An lower border side
5 An upper left corner of the border
6 An upper right corner of the border
7 An lower left corner of the border
8 An lower right corner of the border

package com.example.graphics2d;

import android.R.color;
import android.content.Context;
import android.graphics.Canvas;
import android.graphics.Color;
import android.graphics.Paint;
import android.graphics.Typeface;
import android.view.View;

public class Circle2D extends View {

public Circle2D(Context context) {
super(context);
// TODO Auto-generated constructor stub
}

@Override
protected void onDraw(Canvas canvas) {
// TODO Auto-generated method stub
super.onDraw(canvas);

canvas.drawColor(Color.BLACK);

Paint paint=new Paint(Paint.ANTI_ALIAS_FLAG);

//Typeface face=Typeface.create(Typeface.MONOSPACE, Typeface.BOLD_ITALIC);
Typeface face=Typeface.createFromAsset(getContext().getAssets(), "chess1.ttf");//path দখিয়ে দিলাম।

paint.setColor(Color.CYAN);
paint.setTextSize(20);
paint.setTypeface(face);

canvas.drawText("WwQqRr ",20,20, paint);
canvas.drawText("WwQqRr ",20,40, paint);
canvas.drawText("WwQqRr ",20,120, paint);
canvas.drawText("WwQqRr ",20,150, paint);

paint.setColor(Color.RED);
canvas.drawCircle(canvas.getWidth()/2,canvas.getHeight()/2, canvas.getWidth()/3, paint);

}

}
tree

মন্তব্য করুন

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  পরিবর্তন )

Google photo

You are commenting using your Google account. Log Out /  পরিবর্তন )

Twitter picture

You are commenting using your Twitter account. Log Out /  পরিবর্তন )

Facebook photo

You are commenting using your Facebook account. Log Out /  পরিবর্তন )

Connecting to %s