Android 如何修复TextView字体回退?

Android 如何修复TextView字体回退?,android,fonts,textview,typeface,Android,Fonts,Textview,Typeface,我有一个本地化为多种语言的程序。它在Android4.x上运行良好,但在Android2.3.x上存在字体渲染问题。下面是一个复制它的小例子。任何帮助都将不胜感激 主要活动布局。这里没什么特别的。只有两个TextView视图: <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" xmlns:tools="http://schemas.android.com/tools" andro

我有一个本地化为多种语言的程序。它在Android4.x上运行良好,但在Android2.3.x上存在字体渲染问题。下面是一个复制它的小例子。任何帮助都将不胜感激

主要活动布局。这里没什么特别的。只有两个TextView视图:

<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:tools="http://schemas.android.com/tools"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:orientation="vertical"
    android:padding="10dp" >

    <TextView
        android:id="@+id/text_view1"
        android:layout_width="fill_parent"
        android:layout_height="wrap_content"
        android:layout_marginTop="80dp"
        tools:context=".MainActivity" />

    <TextView
        android:id="@+id/text_view2"
        android:layout_width="fill_parent"
        android:layout_height="wrap_content"
        android:layout_marginTop="80dp"
        tools:context=".MainActivity" />

</LinearLayout>
自定义字体chelsea.ttf来自此处。没什么特别的,我也可以用其他字体复制

文本字符串包含两行,第一行包含非chelsea字体中的unicode字符,第二行包含字体中的字符。第一个文本视图使用自定义字体呈现,第二个文本视图使用常用的san serif字体(包含文本的所有unicode字符)

Android 4.x正确渲染,在需要时故障切换到常用字体:

然而,Android2.3.x并没有正确地呈现它。它确实回到了常用字体(好),但使用了奇怪的指标,导致字符间距过大:

有什么建议可以解决吗?如果需要的话,我愿意采取丑陋的变通办法

package com.font_test;

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

public class MainActivity extends Activity {

    private static final String TEXT = 
            "\u0440\u0443\u0441\u0441\u043A\u0438\u0439" + 
            "\n" + 
            "pyccknn";

    @Override
    public void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_main);

        // Set textview 1
        final Typeface typeface1 = Typeface
                .createFromAsset(getAssets(), "fonts/chelsea.ttf");
        final TextView tv1 = (TextView) findViewById(R.id.text_view1);
        tv1.setTypeface(typeface1);
        tv1.setTextSize(40);
        tv1.setBackgroundColor(0x280000ff);
        tv1.setText(TEXT);

        // Set textview 2
        final Typeface typeface2 = Typeface.SANS_SERIF;
        final TextView tv2 = (TextView) findViewById(R.id.text_view2);
        tv2.setTypeface(typeface2);
        tv2.setTextSize(40);
        tv2.setBackgroundColor(0x280000ff);
        tv2.setText(TEXT);
    }
}