开发者

import fonts into eclipse to support unicode

开发者 https://www.devze.com 2023-01-13 02:41 出处:网络
how can i import musica fonts int开发者_Go百科o eclipse to support musical unicode? Any workaround? This is the simple one.

how can i import musica fonts int开发者_Go百科o eclipse to support musical unicode? Any workaround?


This is the simple one.

create a folder in the root of your project called assets/fonts/ then paste the TTF font file (in this case Verdana.ttf). Then, if you want to apply that font to, say a TextView, do the following:

public class FontSampler extends Activity {
  @Override
  public void onCreate(Bundle icicle) {
    super.onCreate(icicle);
    setContentView(R.layout.main);

    TextView tv=(TextView)findViewById(R.id.custom);
    Typeface face=Typeface.createFromAsset(getAssets(),
                                          "fonts/Verdana.ttf");

    tv.setTypeface(face);
  }
}

This example was taken from the ComonsWare book (written by Mark Murphy). You can download the full example from GitHub .

0

精彩评论

暂无评论...
验证码 换一张
取 消