From ff86bcd08827d1050a8cfd99b521c21848b3f364 Mon Sep 17 00:00:00 2001 From: Raph Levien Date: Mon, 11 Aug 2014 14:26:37 -0700 Subject: [PATCH] Resolve invalid Typeface style to default Setting a textAppearance that specified a fontFamily but not a textStyle results in a styleIndex of -1 being passed to the Typeface.create() call. This patch resolves such invalid style indices to the default. Fix for bug 16880318 "Applying TextAppearance To TextView with custom font family incorrectly adds italics style on LMP" Change-Id: I05c9cfc4d76161be21b58abdb4037c51a23cae37 --- graphics/java/android/graphics/Typeface.java | 3 +++ 1 file changed, 3 insertions(+) diff --git a/graphics/java/android/graphics/Typeface.java b/graphics/java/android/graphics/Typeface.java index 0dc903a9e626b..06586ca85e2d5 100644 --- a/graphics/java/android/graphics/Typeface.java +++ b/graphics/java/android/graphics/Typeface.java @@ -132,6 +132,9 @@ public class Typeface { * @return The best matching typeface. */ public static Typeface create(Typeface family, int style) { + if (style < 0 || style > 3) { + style = 0; + } long ni = 0; if (family != null) { // Return early if we're asked for the same face/style