Merge "Fix NPE and wrong behavior of Typeface.isSupportedAxes" into oc-dev
This commit is contained in:
committed by
Android (Google) Code Review
commit
633b32be55
@@ -1596,10 +1596,13 @@ public class Paint {
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// The null typeface is valid and it is equivalent to Typeface.DEFAULT.
|
||||||
|
// To call isSupportedAxes method, use Typeface.DEFAULT instance.
|
||||||
|
Typeface targetTypeface = mTypeface == null ? Typeface.DEFAULT : mTypeface;
|
||||||
FontVariationAxis[] axes = FontVariationAxis.fromFontVariationSettings(settings);
|
FontVariationAxis[] axes = FontVariationAxis.fromFontVariationSettings(settings);
|
||||||
final ArrayList<FontVariationAxis> filteredAxes = new ArrayList<FontVariationAxis>();
|
final ArrayList<FontVariationAxis> filteredAxes = new ArrayList<FontVariationAxis>();
|
||||||
for (final FontVariationAxis axis : axes) {
|
for (final FontVariationAxis axis : axes) {
|
||||||
if (mTypeface.isSupportedAxes(axis.getOpenTypeTagValue())) {
|
if (targetTypeface.isSupportedAxes(axis.getOpenTypeTagValue())) {
|
||||||
filteredAxes.add(axis);
|
filteredAxes.add(axis);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -1607,7 +1610,7 @@ public class Paint {
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
mFontVariationSettings = settings;
|
mFontVariationSettings = settings;
|
||||||
setTypeface(Typeface.createFromTypefaceWithVariation(mTypeface, filteredAxes));
|
setTypeface(Typeface.createFromTypefaceWithVariation(targetTypeface, filteredAxes));
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -725,8 +725,8 @@ public class Typeface {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/** @hide */
|
/** @hide */
|
||||||
public static Typeface createFromTypefaceWithVariation(Typeface family,
|
public static Typeface createFromTypefaceWithVariation(@Nullable Typeface family,
|
||||||
List<FontVariationAxis> axes) {
|
@NonNull List<FontVariationAxis> axes) {
|
||||||
final long ni = family == null ? 0 : family.native_instance;
|
final long ni = family == null ? 0 : family.native_instance;
|
||||||
return new Typeface(nativeCreateFromTypefaceWithVariation(ni, axes));
|
return new Typeface(nativeCreateFromTypefaceWithVariation(ni, axes));
|
||||||
}
|
}
|
||||||
@@ -1056,7 +1056,7 @@ public class Typeface {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return Arrays.binarySearch(mSupportedAxes, axis) > 0;
|
return Arrays.binarySearch(mSupportedAxes, axis) >= 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
private static native long nativeCreateFromTypeface(long native_instance, int style);
|
private static native long nativeCreateFromTypeface(long native_instance, int style);
|
||||||
|
|||||||
Reference in New Issue
Block a user