2013-12-15 40 views
0

在我正在構建的應用程序中,我想使用標準Apple字體:Myriad Pro。要做到這一點,我已經嘗試使用自定義字體的正常方式:嘗試了一切,但仍然得到「原生字體無法制作」

Typeface myriadPro = Typeface.createFromAsset(getAssets(), "fonts/myriad_pro.ttf"); 

和解決方法的問題是安卓有時有字體作爲討論here

public class Typefaces { 
private static final String TAG = "Typefaces"; 

private static final Hashtable<String, Typeface> cache = new Hashtable<String, Typeface>(); 

public static Typeface get(Context c, String assetPath) { 
    synchronized (cache) { 
     if (!cache.containsKey(assetPath)) { 
      try { 
       Typeface t = Typeface.createFromAsset(c.getAssets(), 
         assetPath); 
       cache.put(assetPath, t); 
      } catch (Exception e) { 
       Log.e(TAG, "Could not get typeface '" + assetPath 
         + "' because " + e.getMessage()); 
       return null; 
      } 
     } 
     return cache.get(assetPath); 
    } 
} 
} 

我已經用OTF和TTF版本的字體嘗試了兩種方法。沒有任何變化的工作。在所有情況下,我都會遇到native typeface cannot be made錯誤(即無法找到字體),即使字體位置正確並且名稱正確。

任何想法什麼仍然會導致此錯誤發生?

回答

1

我有同樣的問題。

轉到AndroidManifest.xml。

minSdkVersion必須爲10或更高。

+0

嗯..我將minSdkVersion更改爲10,但問題仍然存在。 – Zero

+0

奇怪的是,它適用於我。這很奇怪。對於我不完全理解的修復,我感到不舒服。 – mahkie

相關問題