mirror of
https://github.com/zhigang1992/react-native.git
synced 2026-05-10 01:15:00 +08:00
Cache Typefaces in shadow/flat/CustomStyleSpan
Summary: @public `Typeface` handling in `shadow/flat/CustomStyleSpan` wasn't very efficient. This diff introduces `TypefaceCache` to avoid allocating duplicated `Typeface`s. Reviewed By: sriramramani Differential Revision: D2564363
This commit is contained in:
committed by
Ahmed El-Helw
parent
5c2f536e9a
commit
007318eb52
@@ -84,14 +84,10 @@ import android.text.style.MetricAffectingSpan;
|
||||
return;
|
||||
}
|
||||
|
||||
// TODO: optimize this part (implemented in a followup patch)
|
||||
|
||||
if (mFontFamily != null) {
|
||||
// efficient in API 21+
|
||||
typeface = Typeface.create(mFontFamily, newStyle);
|
||||
typeface = TypefaceCache.getTypeface(mFontFamily, newStyle);
|
||||
} else {
|
||||
// efficient in API 16+
|
||||
typeface = Typeface.create(typeface, newStyle);
|
||||
typeface = TypefaceCache.getTypeface(typeface, newStyle);
|
||||
}
|
||||
|
||||
ds.setTypeface(typeface);
|
||||
|
||||
Reference in New Issue
Block a user