diff options
Diffstat (limited to 'graphics/java/android/graphics/FontFamily.java')
-rw-r--r-- | graphics/java/android/graphics/FontFamily.java | 40 |
1 files changed, 14 insertions, 26 deletions
diff --git a/graphics/java/android/graphics/FontFamily.java b/graphics/java/android/graphics/FontFamily.java index d9a77e752823..e7cfcfdf7760 100644 --- a/graphics/java/android/graphics/FontFamily.java +++ b/graphics/java/android/graphics/FontFamily.java @@ -16,10 +16,12 @@ package android.graphics; +import android.annotation.Nullable; import android.content.res.AssetManager; import android.graphics.fonts.FontVariationAxis; -import android.text.FontConfig; +import android.text.TextUtils; import android.util.Log; + import dalvik.annotation.optimization.CriticalNative; import java.io.FileInputStream; @@ -48,8 +50,16 @@ public class FontFamily { mBuilderPtr = nInitBuilder(null, 0); } - public FontFamily(String lang, int variant) { - mBuilderPtr = nInitBuilder(lang, variant); + public FontFamily(@Nullable String[] langs, int variant) { + final String langsString; + if (langs == null || langs.length == 0) { + langsString = null; + } else if (langs.length == 1) { + langsString = langs[0]; + } else { + langsString = TextUtils.join(",", langs); + } + mBuilderPtr = nInitBuilder(langsString, variant); } /** @@ -150,39 +160,17 @@ public class FontFamily { isItalic); } - /** - * Allow creating unsupported FontFamily. - * - * For compatibility reasons, we still need to create a FontFamily object even if Minikin failed - * to find any usable 'cmap' table for some reasons, e.g. broken 'cmap' table, no 'cmap' table - * encoded with Unicode code points, etc. Without calling this method, the freeze() method will - * return null if Minikin fails to find any usable 'cmap' table. By calling this method, the - * freeze() won't fail and will create an empty FontFamily. This empty FontFamily is placed at - * the top of the fallback chain but is never used. if we don't create this empty FontFamily - * and put it at top, bad things (performance regressions, unexpected glyph selection) will - * happen. - */ - public void allowUnsupportedFont() { - if (mBuilderPtr == 0) { - throw new IllegalStateException("Unable to allow unsupported font."); - } - nAllowUnsupportedFont(mBuilderPtr); - } - // TODO: Remove once internal user stop using private API. private static boolean nAddFont(long builderPtr, ByteBuffer font, int ttcIndex) { return nAddFont(builderPtr, font, ttcIndex, -1, -1); } - private static native long nInitBuilder(String lang, int variant); + private static native long nInitBuilder(String langs, int variant); @CriticalNative private static native long nCreateFamily(long mBuilderPtr); @CriticalNative - private static native void nAllowUnsupportedFont(long builderPtr); - - @CriticalNative private static native void nAbort(long mBuilderPtr); @CriticalNative |