문제

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.

도움이 되었습니까?

해결책

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.

라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top