OSDN Git Service

Make sure the Typeface is loaded before calling measureText.
authorSeigo Nonaka <nona@google.com>
Thu, 27 Oct 2016 09:06:39 +0000 (18:06 +0900)
committerSeigo Nonaka <nona@google.com>
Thu, 27 Oct 2016 09:18:49 +0000 (18:18 +0900)
commite2179925df2ce174d81dd6f7abae626cc859ce00
tree94d7ddd2f12843a36327511b01b6618dbfaa12ec
parent4e55f8a47ce1a429347464de7aab9aa014f28920
Make sure the Typeface is loaded before calling measureText.

This is a clean up CL by resolving TODO in hwui/Typeface.cpp

Usually Typeface is listed in preloaded-classes and loaded during Zygote
initialization. However, on some devices, class preloading is disabled.
Paint.measureText can not be called before Typeface static initializer
and it may not load Typeface class.

To ensure that the font preloading happens in ZygoteInit even on such
devices, refer Typeface.DEFAULT static field in TextView.preloadFontCache
in TextView which also happens during zygote initialization.

Bug: 32374752
Test: Manually done
Change-Id: I773c154671c170bebad3aa0f9c04eee5a664b849
core/java/android/widget/TextView.java
libs/hwui/hwui/Typeface.cpp