Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit e5f73f1c authored by Seigo Nonaka's avatar Seigo Nonaka
Browse files

Add new API for returning max custom fallback families

Bug: 119620208
Test: TypefaceCustomFallbackBuilderTest
Change-Id: I7ef69bdebdce7d5dc4cbea2d30965c93197e965f
parent 4445345f
Loading
Loading
Loading
Loading
+1 −0
Original line number Diff line number Diff line
@@ -14797,6 +14797,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);
  }
+13 −2
Original line number Diff line number Diff line
@@ -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;
        }