본문 바로가기

나의 플랫폼/안드로이드

[Android] Font Library

336x280(권장), 300x250(권장), 250x250, 200x200 크기의 광고 코드만 넣을 수 있습니다.

디폴트 폰트를 바꾸기에 좋은 Library가 있어 공유하고자 합니다.


https://github.com/tsengvn/typekit



1. main/assets 폴더 를 만든 후, 해당 폴더에 ttf나 otf 같은 폰트 파일을 복사 합니다.


Typekit is a library that help you quick change default font of your android application. You don't need to add any custom view or tag to your current xml layout file. You make a quick config in your application class and change the font that you need specific for a style.

Override this in your base activity

2. Activity에 아래 소스 추가

@Override
    protected void attachBaseContext(Context newBase) {
        super.attachBaseContext(TypekitContextWrapper.wrap(newBase));
    }

and make the setup for fonts in your custom application class

3. Application에 아래 소스 추가

Typekit.getInstance()
                .addNormal(Typekit.createFromAsset(this, "Wedding Chardonnay.ttf"))
                .addBold(Typekit.createFromAsset(this, "Double_Bubble_shadow.otf"))
                .addItalic(Typekit.createFromAsset(this, "Double_Bubble_shadow_italic.otf"))
                .addBoldItalic(Typekit.createFromAsset(this, "Double_Bubble_shadow_italic.otf"))
                .addCustom1(Typekit.createFromAsset(this, "soopafre.ttf"))
                .addCustom2(Typekit.createFromAsset(this, "Break It Down.ttf"));

Now the custom font is ready for any class which is subclass of TextView

Dependency

dependencies {
    compile 'com.tsengvn:Typekit:1.0.0

}


그럼 끝!


정말 간단합니다.