Improved error handling when font loading fails.
Without this patch, an application could trigger a platform crash
by calling:
Typeface typeface = Typeface.createFromFile("");
boolean isbold = typeface.isBold();
The crash occurs since the Skia error that occurs when font loading
fails is not propagated.
With this patch, the Typeface constructor throws an
IllegalStateException when Skia fails to load the font (i.e. when
the native instance is null).
Change-Id: I1002b37b7b32840cb7eeef6819d2982cb18c9003
This commit is contained in:
committed by
Johan Redestig
parent
5a870fee53
commit
417675cab0
@@ -143,6 +143,9 @@ public class Typeface {
|
||||
|
||||
// don't allow clients to call this directly
|
||||
private Typeface(int ni) {
|
||||
if (ni == 0) {
|
||||
throw new IllegalStateException();
|
||||
}
|
||||
native_instance = ni;
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user