Loading tools/layoutlib/bridge/src/android/graphics/FontFamily_Delegate.java +8 −0 Original line number Diff line number Diff line Loading @@ -411,6 +411,14 @@ public class FontFamily_Delegate { sManager.removeJavaReferenceFor(builderPtr); } /** * @see FontFamily#allowUnsupportedFont */ @LayoutlibDelegate /*package*/ static void nAllowUnsupportedFont(long builderPtr) { // Do nothing here as this is used for Minikin fonts } // ---- private helper methods ---- private void init() { Loading tools/layoutlib/bridge/src/android/graphics/Typeface_Delegate.java +42 −9 Original line number Diff line number Diff line Loading @@ -90,9 +90,12 @@ public final class Typeface_Delegate { assert variant != FontVariant.NONE; // Calculate the required weight based on style and weight of this typeface. int weight = mWeight + ((mStyle & Font.BOLD) == 0 ? 0 : FontFamily_Delegate.BOLD_FONT_WEIGHT_DELTA); if (weight > 900) { weight = 900; int weight = mWeight + 50 + ((mStyle & Font.BOLD) == 0 ? 0 : FontFamily_Delegate.BOLD_FONT_WEIGHT_DELTA); if (weight > 1000) { weight = 1000; } else if (weight < 100) { weight = 100; } final boolean isItalic = (mStyle & Font.ITALIC) != 0; List<Font> fonts = new ArrayList<Font>(mFontFamilies.length); Loading Loading @@ -162,6 +165,22 @@ public final class Typeface_Delegate { delegate.mWeight)); } @LayoutlibDelegate /*package*/ static long nativeCreateFromTypefaceWithExactStyle(long native_instance, int weight, boolean italic) { Typeface_Delegate delegate = sManager.getDelegate(native_instance); if (delegate == null) { delegate = sManager.getDelegate(sDefaultTypeface); } if (delegate == null) { return 0; } int style = weight >= 600 ? (italic ? Typeface.BOLD_ITALIC : Typeface.BOLD) : (italic ? Typeface.ITALIC : Typeface.NORMAL); return sManager.addNewDelegate(new Typeface_Delegate(delegate.mFontFamilies, style, weight)); } @LayoutlibDelegate /*package*/ static synchronized long nativeCreateFromTypefaceWithVariation(long native_instance, List<FontVariationAxis> axes) { Loading Loading @@ -195,12 +214,21 @@ public final class Typeface_Delegate { } @LayoutlibDelegate /*package*/ static synchronized long nativeCreateFromArray(long[] familyArray) { /*package*/ static synchronized long nativeCreateFromArray(long[] familyArray, int weight, int italic) { FontFamily_Delegate[] fontFamilies = new FontFamily_Delegate[familyArray.length]; for (int i = 0; i < familyArray.length; i++) { fontFamilies[i] = FontFamily_Delegate.getDelegate(familyArray[i]); } Typeface_Delegate delegate = new Typeface_Delegate(fontFamilies, Typeface.NORMAL); if (weight == Typeface.RESOLVE_BY_FONT_TABLE) { weight = 400; } if (italic == Typeface.RESOLVE_BY_FONT_TABLE) { italic = 0; } int style = weight >= 600 ? (italic == 1 ? Typeface.BOLD_ITALIC : Typeface.BOLD) : (italic == 1 ? Typeface.ITALIC : Typeface.NORMAL); Typeface_Delegate delegate = new Typeface_Delegate(fontFamilies, style, weight); return sManager.addNewDelegate(delegate); } Loading @@ -224,6 +252,15 @@ public final class Typeface_Delegate { sDefaultTypeface = native_instance; } @LayoutlibDelegate /*package*/ static int nativeGetBaseWeight(long native_instance) { Typeface_Delegate delegate = sManager.getDelegate(native_instance); if (delegate == null) { return 0; } return delegate.mWeight; } @LayoutlibDelegate /*package*/ static File getSystemFontConfigLocation() { return new File(getFontLocation()); Loading @@ -244,10 +281,6 @@ public final class Typeface_Delegate { // ---- Private delegate/helper methods ---- private Typeface_Delegate(@NonNull FontFamily_Delegate[] fontFamilies, int style) { this(fontFamilies, style, FontFamily_Delegate.DEFAULT_FONT_WEIGHT); } public Typeface_Delegate(@NonNull FontFamily_Delegate[] fontFamilies, int style, int weight) { mFontFamilies = fontFamilies; mStyle = style; Loading Loading
tools/layoutlib/bridge/src/android/graphics/FontFamily_Delegate.java +8 −0 Original line number Diff line number Diff line Loading @@ -411,6 +411,14 @@ public class FontFamily_Delegate { sManager.removeJavaReferenceFor(builderPtr); } /** * @see FontFamily#allowUnsupportedFont */ @LayoutlibDelegate /*package*/ static void nAllowUnsupportedFont(long builderPtr) { // Do nothing here as this is used for Minikin fonts } // ---- private helper methods ---- private void init() { Loading
tools/layoutlib/bridge/src/android/graphics/Typeface_Delegate.java +42 −9 Original line number Diff line number Diff line Loading @@ -90,9 +90,12 @@ public final class Typeface_Delegate { assert variant != FontVariant.NONE; // Calculate the required weight based on style and weight of this typeface. int weight = mWeight + ((mStyle & Font.BOLD) == 0 ? 0 : FontFamily_Delegate.BOLD_FONT_WEIGHT_DELTA); if (weight > 900) { weight = 900; int weight = mWeight + 50 + ((mStyle & Font.BOLD) == 0 ? 0 : FontFamily_Delegate.BOLD_FONT_WEIGHT_DELTA); if (weight > 1000) { weight = 1000; } else if (weight < 100) { weight = 100; } final boolean isItalic = (mStyle & Font.ITALIC) != 0; List<Font> fonts = new ArrayList<Font>(mFontFamilies.length); Loading Loading @@ -162,6 +165,22 @@ public final class Typeface_Delegate { delegate.mWeight)); } @LayoutlibDelegate /*package*/ static long nativeCreateFromTypefaceWithExactStyle(long native_instance, int weight, boolean italic) { Typeface_Delegate delegate = sManager.getDelegate(native_instance); if (delegate == null) { delegate = sManager.getDelegate(sDefaultTypeface); } if (delegate == null) { return 0; } int style = weight >= 600 ? (italic ? Typeface.BOLD_ITALIC : Typeface.BOLD) : (italic ? Typeface.ITALIC : Typeface.NORMAL); return sManager.addNewDelegate(new Typeface_Delegate(delegate.mFontFamilies, style, weight)); } @LayoutlibDelegate /*package*/ static synchronized long nativeCreateFromTypefaceWithVariation(long native_instance, List<FontVariationAxis> axes) { Loading Loading @@ -195,12 +214,21 @@ public final class Typeface_Delegate { } @LayoutlibDelegate /*package*/ static synchronized long nativeCreateFromArray(long[] familyArray) { /*package*/ static synchronized long nativeCreateFromArray(long[] familyArray, int weight, int italic) { FontFamily_Delegate[] fontFamilies = new FontFamily_Delegate[familyArray.length]; for (int i = 0; i < familyArray.length; i++) { fontFamilies[i] = FontFamily_Delegate.getDelegate(familyArray[i]); } Typeface_Delegate delegate = new Typeface_Delegate(fontFamilies, Typeface.NORMAL); if (weight == Typeface.RESOLVE_BY_FONT_TABLE) { weight = 400; } if (italic == Typeface.RESOLVE_BY_FONT_TABLE) { italic = 0; } int style = weight >= 600 ? (italic == 1 ? Typeface.BOLD_ITALIC : Typeface.BOLD) : (italic == 1 ? Typeface.ITALIC : Typeface.NORMAL); Typeface_Delegate delegate = new Typeface_Delegate(fontFamilies, style, weight); return sManager.addNewDelegate(delegate); } Loading @@ -224,6 +252,15 @@ public final class Typeface_Delegate { sDefaultTypeface = native_instance; } @LayoutlibDelegate /*package*/ static int nativeGetBaseWeight(long native_instance) { Typeface_Delegate delegate = sManager.getDelegate(native_instance); if (delegate == null) { return 0; } return delegate.mWeight; } @LayoutlibDelegate /*package*/ static File getSystemFontConfigLocation() { return new File(getFontLocation()); Loading @@ -244,10 +281,6 @@ public final class Typeface_Delegate { // ---- Private delegate/helper methods ---- private Typeface_Delegate(@NonNull FontFamily_Delegate[] fontFamilies, int style) { this(fontFamilies, style, FontFamily_Delegate.DEFAULT_FONT_WEIGHT); } public Typeface_Delegate(@NonNull FontFamily_Delegate[] fontFamilies, int style, int weight) { mFontFamilies = fontFamilies; mStyle = style; Loading