Question

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.

Was it helpful?

Solution

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.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top