안드로이드 2.2 이하는 4메가 이상 폰트를 로드 할 수 없다.


로드가 안된 상태에서 텍스트를 셋팅하다 보면 어플이 뻗는다.


해결 방안으로는 로드 실패시 시스템 폰트로 로드 시키거나.


sd카드에서 폰트를 로드시키면 된다.


1번 해결 방안

paint.setTypeface(typeFace);
               
FontMetricsInt fm = paint.getFontMetricsInt();
 int h = (int) Math.ceil(fm.bottom - fm.top);
               
//폰트가 제대로 안만들어 진 상태 그래서 기본 폰트 사용
 if(h == 0)
{
        paint.setTypeface(Typeface.create("Arial", Typeface.NORMAL));
}



2번 해결방안


final Typeface typeface = Typeface.createFromAsset(pContext.getAssets(), pAssetName);

createFromAsset 이 함수 말고 createFromFile 이 함수 사용 하면 된다.

final Typeface typeface = Typeface.createFromFile("mnt/sdcard/폰트경로")

이렇게하면 1메가 넘는 폰트도 사용할 수 있다.


어차리 요즘은 2.2이하는 거의 없으므로 그냥 시스템 폰트 쓰는걸 추천한다.




Posted by 부우산사나이
: