Merge "Add new API for returning max custom fallback families"

This commit is contained in:
TreeHugger Robot
2018-11-28 03:11:29 +00:00
committed by Android (Google) Code Review
2 changed files with 14 additions and 2 deletions

View File

@@ -14823,6 +14823,7 @@ package android.graphics {
ctor public Typeface.CustomFallbackBuilder(android.graphics.fonts.FontFamily);
method public android.graphics.Typeface.CustomFallbackBuilder addCustomFallback(android.graphics.fonts.FontFamily);
method public android.graphics.Typeface build();
method public static int getMaxCustomFallbackCount();
method public android.graphics.Typeface.CustomFallbackBuilder setStyle(android.graphics.fonts.FontStyle);
method public android.graphics.Typeface.CustomFallbackBuilder setSystemFallback(java.lang.String);
}

View File

@@ -651,6 +651,17 @@ public class Typeface {
private String mFallbackName = null;
private @Nullable FontStyle mStyle;
/**
* Returns the maximum capacity of custom fallback families.
*
* This includes the the first font family passed to the constructor.
*
* @return the maximum number of font families for the custom fallback
*/
public static @IntRange(from = 1) int getMaxCustomFallbackCount() {
return MAX_CUSTOM_FALLBACK;
}
/**
* Constructs a builder with a font family.
*
@@ -706,8 +717,8 @@ public class Typeface {
*/
public CustomFallbackBuilder addCustomFallback(@NonNull FontFamily family) {
Preconditions.checkNotNull(family);
Preconditions.checkArgument(mFamilies.size() < MAX_CUSTOM_FALLBACK,
"Custom fallback limit exceeded(" + MAX_CUSTOM_FALLBACK + ")");
Preconditions.checkArgument(mFamilies.size() < getMaxCustomFallbackCount(),
"Custom fallback limit exceeded(" + getMaxCustomFallbackCount() + ")");
mFamilies.add(family);
return this;
}