2016-10-24 44 views
0

我正在使用Montserrat-Bold.otf字體在我的應用程序中是泰語。有些設備上的字符部分可見。我的意思是一些字符的頂部不可見(如剪切)。請參閱圖片。隨機設備上的字體不同

Normal ViewExample of non normal view

而且Java代碼

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

     ((TextView) findViewById(R.id.tv)).setTypeface(Typeface.createFromAsset(getAssets(), 
       "Montserrat-Bold.otf")); 
    } 

和XML

<?xml version="1.0" encoding="utf-8"?> 
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android" 
    xmlns:tools="http://schemas.android.com/tools" 
    android:id="@+id/activity_main" 
    android:layout_width="match_parent" 
    android:layout_height="match_parent" 
    android:paddingBottom="@dimen/activity_vertical_margin" 
    android:paddingLeft="@dimen/activity_horizontal_margin" 
    android:paddingRight="@dimen/activity_horizontal_margin" 
    android:paddingTop="@dimen/activity_vertical_margin" 
    tools:context="com.example.hayk.temp.MainActivity"> 

    <TextView 
     android:id="@+id/tv" 
     android:layout_width="wrap_content" 
     android:layout_height="wrap_content" 
     android:text="รายการนี้ถูกแลกแล้ว" 
     android:layout_centerInParent="true" 
     android:textSize="30sp"/> 
</RelativeLayout> 

附:我想提一下,當我用相同的字體打開帶有泰文單詞的網頁時,我沒有這種問題。

+0

你需要在這裏添加更多的信息 - 哪些版本的Android,你看到這個,你用哪個SDK來建立你的應用程序等等。這兩者都很大程度上決定了您可以使用哪些功能,並且您應該查看平臺是否支持您嘗試使用的功能(本例中爲'otf' flavored OpenType字體)「你的目標,以及你用來編譯你的代碼的SDK。 –

+0

Android版本是4.4.4,三星Galaxy S4 compileSdkVersion 23 你的意思是如果我將在Android 4.4.4版本的其他設備上測試應用程序,我也會遇到這個問題嗎? –

+1

似乎很有可能。 4. *在支持'otf'時仍然沒有完成,所以根據這個字體的「正確」,這可能會導致運行Android 4的任何設備出現問題。* –

回答

0

Android不支持OpenType(.otf)。

使用TrueType(.ttf)字體。

顯然某些設備支持OpenType。但它最初並不支持,所以你會想要使用任何字體更好的方式是使用.ttf

+1

這顯然不正確?現代Android支持'otf'就好了(甚至支持大多數otf)。此外,您在這裏使用了大量的誤用詞:ttf和otf都是OpenType字體;你可能在推文中不精確,但不會在SO回答中。舊版本的Android本身並不支持CFF數據('otf')的OpenType字體,只支持帶有TrueType輪廓('ttf')的OpenType字體。 Android的新版本支持完美無瑕。 –