assests フォルダーからフォント ファイルを取得するコードは次のとおりです。
public static Typeface getMyFont(Context context, String resource) {
InputStream is;
Typeface font = null;
ClassLoader classLoader = Thread.currentThread().getContextClassLoader();
AssetManager assetManager = context.getResources().getAssets();
try {
is = classLoader.getResourceAsStream(resource);
is = assetManager.open(resource);
BufferedReader br = new BufferedReader(new InputStreamReader(is));
String line = null;
while ((line = br.readLine()) != null) {
Log.e("wwwww", line);
}
br.close();
font = Typeface.createFromAsset(context.getAssets(), line);
} catch (IOException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
return font;
}
ここでのリソースは、リンクされている assests フォルダーの font/MYFONT.ttf (ショートカット) ですが、次の行で nullpointer 例外が発生します。
font = Typeface.createFromAsset(context.getAssets(), line);