如何以调整阿拉伯语'aarab'字?请参阅我的code阿拉伯语、我的、aarab、code

2023-09-04 10:36:03 作者:嫣然丶回眸

我想显示阿拉伯语文本自定义字体。我的code是如下:

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();
            }
    }

}

和arabic_display.xml是:

<?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> 

其中RES /生/为arabic_text.txt是为显示在记事本(字体名称:me_quran.ttf和字体大小40)

但在模拟器中它显示为:

but in simulator it is shown as:

您可以看到,小字符(称为aaraab阿拉伯文字符),不进行调整所有..我应该如何解决这一问题? ////////////////////////////////////////////////// ///////////////// ///////////

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

//// /////

//// /////

结果来DroidSansArabic.ttf在的

RESULT AFTER USING DroidSansArabic.ttf

推荐答案

在字符映射判断在me_quran.ttf的,它看起来像模拟器是什么表现是它应该显示。 这种字体看上去与我见过的其他阿拉伯字体的方式太不一样了,你可能想要得到另一种字体的保持。

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.