2

Here is my code for Bangla in Android:

package com.exam;

import android.app.Activity;
import android.graphics.Typeface;
import android.os.Bundle;
import android.widget.TextView;

public class TextDifferentActivity extends Activity {
    @Override
    public void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.main);

        Typeface tf = Typeface.createFromAsset(getAssets(),
                "fonts/DroidSansFallback.ttf");
        TextView tv = (TextView) findViewById(R.id.CustomFontText);
        tv.setTypeface(tf);
    }
}

XML code

<?xml version="1.0" encoding="utf-8"?>
<LinearLayout
xmlns:android="http://schemas.android.com/apk/res/android"
android:orientation="vertical"
android:layout_width="fill_parent"
android:layout_height="fill_parent">
<TextView
    android:id="@+id/DefaultFontText"
    android:layout_width="fill_parent"
    android:layout_height="wrap_content"
    android:textSize="30sp"
    android:text="Here is some text." />
<TextView
    android:id="@+id/CustomFontText"
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:textSize="30sp"
    android:text="আল্লাহ">
    </TextView>
</LinearLayout>

Here it shows আ্ললাহ।, but I need to show it as আল্লাহ. How can I solve the problem? In my phone, HTC A3333, it shows the fonts. Is there any other solution to make it correct?

Lenin
  • 570
  • 16
  • 36
Android Girl
  • 2,074
  • 3
  • 22
  • 29

1 Answers1

2

Whatever you do complex glyphs (juktoborno) are always shown as broken characters, only solution i found is to use images for them. You can use SpannableStringBuilder for this purpose.But using image only for juktoborno is not perfect because image doesn't synchronize perfectly with characters of the font as shown below: enter image description here

So you need replace all characters with images which makes the no of images required pretty high. But no of images can be reduced greatly by using Overlay technique. This is what I achieved finally: enter image description here

Imran Rana
  • 11,899
  • 7
  • 45
  • 51