Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7493305
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 29, 20262026-05-29T16:53:11+00:00 2026-05-29T16:53:11+00:00

I am trying to display arabic text with custom font. my code is as

  • 0

I am trying to display arabic text with custom font. my code is as following:

package com.androidbook.test;

import java.io.BufferedInputStream;
import java.io.InputStream;

import org.apache.http.util.ByteArrayBuffer;

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

public class ArabicTextActivity extends Activity {

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        // TODO Auto-generated method stub
        super.onCreate(savedInstanceState);
        setContentView(R.layout.arabic_display);

        TextView arabicTextView;
          Typeface arabicFont;

          arabicTextView = (TextView)findViewById(R.id.arabicTextDisplayTextView);
          arabicFont =Typeface.createFromAsset(getAssets(),"me_quran.ttf");
          arabicTextView.setTypeface(arabicFont);     
          arabicTextView.setTextSize(40);

            InputStream is = getResources().openRawResource(R.raw.arabic_text); 
            BufferedInputStream bis = new BufferedInputStream(is);
            int myInt=0;

            try{
                ByteArrayBuffer myByteArray = new ByteArrayBuffer(100); 
                while((myInt = bis.read())!=-1)
                {
                    if(myInt == 10) break;
                    myByteArray.append((byte)myInt);
                }

                String arabicLine = new String(myByteArray.toByteArray(), 0, myByteArray.length(), "UTF-8");
                arabicTextView.setText(arabicLine);
            }catch(Exception ex)
            {
                ex.printStackTrace();
            }
    }

}

and arabic_display.xml is:

<?xml version="1.0" encoding="utf-8"?>
    <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
        android:id="@+id/quranDisplayItemLinearLayout"
        android:layout_width="fill_parent"
        android:layout_height="fill_parent" 
        android:orientation="vertical">

        <TextView
            android:id="@+id/arabicTextDisplayTextView"
            android:layout_width="fill_parent"
            android:layout_height="fill_parent"
            android:text="Arabic" />

    </LinearLayout> 

where res/raw/as arabic_text.txt is displayed in notepad as (font name: me_quran.ttf and font size 40)

enter image description here

but in simulator it is shown as:

enter image description here

you can notice that small characters (called aaraab characters in arabic) are not adjusted at all.. how should i fix this?
///////////////////////////////////////////////////////////////////
///////////

////
/////

RESULT AFTER USING DroidSansArabic.ttf

enter image description here

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-29T16:53:12+00:00Added an answer on May 29, 2026 at 4:53 pm

    Judging by the charmap of the “me_quran.ttf” , it looks like what the simulator is showing is what it ought to show.
    This font looks way too different from other arabic fonts that I’ve seen, you might want to get a hold on another font.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm trying to draw Arabic text onto a Bitmap for display: Bitmap img =
I've been trying to display text using a Quartz context, but no matter what
Trying to display a message for each text box which the user didn't enter
I'm trying to display text in my OpenGL / JOGL app. Here is some
I' trying to display an image along with some text as a listbox item
Im trying to display text but that isnt working. I create a dynamic text
I am trying display customized text behind my embedded Flash swf file on HTML.
I'm trying to display tooltips in Java which may or may not be paragraph-length.
I am trying to display random images heres my code private void Page_Load(object sender,
I'm trying to display the content of a byte array in a text file.

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.