diff options
| author | 2019-03-20 20:11:14 +0000 | |
|---|---|---|
| committer | 2019-03-20 20:11:14 +0000 | |
| commit | be1d460a8892e3221ed0631e6638523a91a5a668 (patch) | |
| tree | 95f627eeca9e64d01f730a45682653d3873f5343 /graphics/java/android | |
| parent | 67122808dcae7f21c953c818dcd81da3271e4a66 (diff) | |
| parent | 7d3d2aa286f59faad3fec15e9dbd3aee42d1da95 (diff) | |
Merge "Revive the old behavior of unsupported filed in public APIs"
Diffstat (limited to 'graphics/java/android')
| -rw-r--r-- | graphics/java/android/graphics/Typeface.java | 17 |
1 files changed, 5 insertions, 12 deletions
diff --git a/graphics/java/android/graphics/Typeface.java b/graphics/java/android/graphics/Typeface.java index 9995f1e73018..c8b361bbff2f 100644 --- a/graphics/java/android/graphics/Typeface.java +++ b/graphics/java/android/graphics/Typeface.java @@ -33,7 +33,6 @@ 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; @@ -48,7 +47,6 @@ 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; @@ -266,16 +264,7 @@ public class Typeface { if (familyBuilder == null) { familyBuilder = new FontFamily.Builder(fontBuilder.build()); } else { - try { - familyBuilder.addFont(fontBuilder.build()); - } catch (IllegalArgumentException e) { - if (VMRuntime.getRuntime().getTargetSdkVersion() <= VERSION_CODES.P) { - // Surpress the IllegalArgumentException for keeping the backward - // compatibility. - continue; - } - throw e; - } + familyBuilder.addFont(fontBuilder.build()); } } if (familyBuilder == null) { @@ -297,6 +286,10 @@ public class Typeface { typeface = new Typeface.CustomFallbackBuilder(family) .setStyle(bestFont.getStyle()) .build(); + } catch (IllegalArgumentException e) { + // To be a compatible behavior with API28 or before, catch IllegalArgumentExcetpion + // thrown by native code and returns null. + return null; } catch (IOException e) { typeface = Typeface.DEFAULT; } |