Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Does Typeface.createFromAsset() cache?

Simple question: Does Typeface.createFromAsset() cache? Or should I just keep a reference around in memory to keep handy? The reason why I ask is because I use it quite a lot (all to maintain a single font across many activities / views), so I'm wondering if Typeface will do a simple bit of caching so I don't have to maintain the reference myself.

like image 674
David Liu Avatar asked Dec 01 '10 00:12

David Liu


1 Answers

It doesn't, as best I can tell -- it directly calls down into

http://google.com/codesearch/p?hl=en#uX1GffpyOZk/core/jni/android/graphics/Typeface.cpp&l=115

which looks like it will always open an Asset and create a new typeface for the stream. You can probably double check this yourself; just check and see if you get the same Typeface object from multiple calls to createFromAsset with the same asset.

like image 142
vvuk Avatar answered Sep 21 '22 01:09

vvuk