summaryrefslogtreecommitdiff
path: root/graphics/java/android
diff options
context:
space:
mode:
author Seigo Nonaka <nona@google.com> 2019-03-15 21:07:44 +0000
committer Seigo Nonaka <nona@google.com> 2019-03-15 21:07:44 +0000
commit848e83f6631c939301929f45abd805770bcbcd76 (patch)
treec0a26d527b3b00f1eb9c4ff5c3f88691fb8755e4 /graphics/java/android
parent96e93959fb8cb27db1829b28113558cc8136c858 (diff)
Revert "Always suppress font error during resource loading"
This reverts commit 96e93959fb8cb27db1829b28113558cc8136c858. Reason for revert: This breaks CTS. Looks like even in old devices, we tells errors to developers. Just suppression is not a right solution here. Change-Id: Ia1b1916d94d115174afe8e822fc669b37e5f3937
Diffstat (limited to 'graphics/java/android')
-rw-r--r--graphics/java/android/graphics/Typeface.java30
-rw-r--r--graphics/java/android/graphics/fonts/Font.java4
2 files changed, 10 insertions, 24 deletions
diff --git a/graphics/java/android/graphics/Typeface.java b/graphics/java/android/graphics/Typeface.java
index 86f658b4a48e..95187149b985 100644
--- a/graphics/java/android/graphics/Typeface.java
+++ b/graphics/java/android/graphics/Typeface.java
@@ -33,12 +33,12 @@ import android.graphics.fonts.FontStyle;
import android.graphics.fonts.FontVariationAxis;
import android.graphics.fonts.SystemFonts;
import android.os.Build;
+import android.os.Build.VERSION_CODES;
import android.os.ParcelFileDescriptor;
import android.provider.FontRequest;
import android.provider.FontsContract;
import android.text.FontConfig;
import android.util.Base64;
-import android.util.Log;
import android.util.LongSparseArray;
import android.util.LruCache;
import android.util.SparseArray;
@@ -48,6 +48,7 @@ import com.android.internal.annotations.VisibleForTesting;
import com.android.internal.util.Preconditions;
import dalvik.annotation.optimization.CriticalNative;
+import dalvik.system.VMRuntime;
import libcore.util.NativeAllocationRegistry;
@@ -261,29 +262,18 @@ public class Typeface {
? FontStyle.FONT_SLANT_ITALIC : FontStyle.FONT_SLANT_UPRIGHT);
}
- Font font = null;
- try {
- font = fontBuilder.build();
- } catch (IllegalArgumentException e) {
- // The exception happens if the unsupported font is passed. We suppress this
- // exception and just ignore this font here since there is no way of
- // resolving this issue by users during inflating layout.
- Log.w(TAG, "Ignoring font file since failed to create font object."
- + " The font file is not supported on this platform.");
- continue;
- }
if (familyBuilder == null) {
- familyBuilder = new FontFamily.Builder(font);
+ familyBuilder = new FontFamily.Builder(fontBuilder.build());
} else {
try {
- familyBuilder.addFont(font);
+ familyBuilder.addFont(fontBuilder.build());
} catch (IllegalArgumentException e) {
- // The exception happens if the same style is added to the family.
- // We suppress this exception and just ignore this font here since there is
- // no way of resolving this issue by users during inflating layout.
- Log.w(TAG,
- "Ignoring font file since the same style font is already added.");
- continue;
+ if (VMRuntime.getRuntime().getTargetSdkVersion() <= VERSION_CODES.P) {
+ // Surpress the IllegalArgumentException for keeping the backward
+ // compatibility.
+ continue;
+ }
+ throw e;
}
}
}
diff --git a/graphics/java/android/graphics/fonts/Font.java b/graphics/java/android/graphics/fonts/Font.java
index f92802f5b574..f715f43344d3 100644
--- a/graphics/java/android/graphics/fonts/Font.java
+++ b/graphics/java/android/graphics/fonts/Font.java
@@ -354,10 +354,6 @@ public final class Font {
/**
* Creates the font based on the configured values.
- *
- * If the font is not supported by the platform, this function will fail with
- * {@link IllegalArgumentException}.
- *
* @return the Font object
*/
public @Nullable Font build() throws IOException {