2017年3月1日 星期三

Custom Fonts

Custom Fonts


Custom Fonts:自己定義字體。可以在網路上下載所需的字體,放入assets/fonts



         放入assets/fonts後,宣告TextView。

  TextView text = (TextView)findViewById(R.id.textview1);


        宣告textview後,呼叫createFromAsset(),從assets的fonts自己定義字體。


 Typeface custom_font = Typeface.createFromAsset(getAssets(), "fonts/font name.ttf");

    createFromAsset(AssetManager mgr, String path)通過從Asset中獲取外部字體來顯示字體樣式。

         最後,自己定義字體套用到TextView的字體上,要用setTypeface()

    text.setTypeface(custom_font);


   處理字體方法


  create(String familyName, int style):直接通過指定字體來加載系統中自帶的文字樣式。

    create(Typeface family, int style)通過其它Typeface變量來構建文字樣式。

    createFromFile(String path)從路徑創立。

    defaultFromStyle(int style)創立默認字體。
   
    getStyle()返回字樣的內在樣式屬性。

  
  

參考文獻


Android - Custom Fonts

Android自定義字體

Typeface

Android字體Font相關知識(create)

android paint類函數講解(一) (create)
http://www.itread01.com/articles/1478401621.html

Free Chinese fonts
http://www.clearchinese.com/resources/fonts.htm

《字體安裝》繁體中文字體免費下載,超多可愛、個性文字任你用。
https://www.pkstep.com/archives/5693



沒有留言:

張貼留言