Loading tools/layoutlib/bridge/src/android/graphics/FontFamily_Delegate.java +16 −8 Original line number Diff line number Diff line Loading @@ -248,14 +248,17 @@ public class FontFamily_Delegate { // ---- delegate methods ---- @LayoutlibDelegate /*package*/ static boolean addFont(FontFamily thisFontFamily, String path, int ttcIndex) { final FontFamily_Delegate delegate = getDelegate(thisFontFamily.mNativePtr); if (thisFontFamily.mBuilderPtr == 0) { throw new IllegalStateException("Unable to call addFont after freezing."); } final FontFamily_Delegate delegate = getDelegate(thisFontFamily.mBuilderPtr); return delegate != null && delegate.addFont(path, ttcIndex); } // ---- native methods ---- @LayoutlibDelegate /*package*/ static long nCreateFamily(String lang, int variant) { /*package*/ static long nInitBuilder(String lang, int variant) { // TODO: support lang. This is required for japanese locale. FontFamily_Delegate delegate = new FontFamily_Delegate(); // variant can be 0, 1 or 2. Loading @@ -269,6 +272,11 @@ public class FontFamily_Delegate { return sManager.addNewDelegate(delegate); } @LayoutlibDelegate /*package*/ static long nCreateFamily(long builderPtr) { return builderPtr; } @LayoutlibDelegate /*package*/ static void nUnrefFamily(long nativePtr) { // Removing the java reference for the object doesn't mean that it's freed for garbage Loading @@ -277,22 +285,22 @@ public class FontFamily_Delegate { } @LayoutlibDelegate /*package*/ static boolean nAddFont(long nativeFamily, ByteBuffer font, int ttcIndex) { /*package*/ static boolean nAddFont(long builderPtr, ByteBuffer font, int ttcIndex) { assert false : "The only client of this method has been overriden."; return false; } @LayoutlibDelegate /*package*/ static boolean nAddFontWeightStyle(long nativeFamily, ByteBuffer font, /*package*/ static boolean nAddFontWeightStyle(long builderPtr, ByteBuffer font, int ttcIndex, List<FontListParser.Axis> listOfAxis, int weight, boolean isItalic) { assert false : "The only client of this method has been overriden."; return false; } static boolean addFont(long nativeFamily, final String path, final int weight, static boolean addFont(long builderPtr, final String path, final int weight, final boolean isItalic) { final FontFamily_Delegate delegate = getDelegate(nativeFamily); final FontFamily_Delegate delegate = getDelegate(builderPtr); if (delegate != null) { if (sFontLocation == null) { delegate.mPostInitRunnables.add(() -> delegate.addFont(path, weight, isItalic)); Loading @@ -304,8 +312,8 @@ public class FontFamily_Delegate { } @LayoutlibDelegate /*package*/ static boolean nAddFontFromAsset(long nativeFamily, AssetManager mgr, String path) { FontFamily_Delegate ffd = sManager.getDelegate(nativeFamily); /*package*/ static boolean nAddFontFromAsset(long builderPtr, AssetManager mgr, String path) { FontFamily_Delegate ffd = sManager.getDelegate(builderPtr); if (ffd == null) { return false; } Loading tools/layoutlib/bridge/src/android/graphics/Typeface_Delegate.java +2 −1 Original line number Diff line number Diff line Loading @@ -212,9 +212,10 @@ public final class Typeface_Delegate { Map<String, ByteBuffer> bufferForPath) { FontFamily fontFamily = new FontFamily(family.lang, family.variant); for (FontListParser.Font font : family.fonts) { FontFamily_Delegate.addFont(fontFamily.mNativePtr, font.fontName, font.weight, FontFamily_Delegate.addFont(fontFamily.mBuilderPtr, font.fontName, font.weight, font.isItalic); } fontFamily.freeze(); return fontFamily; } Loading tools/layoutlib/create/src/com/android/tools/layoutlib/create/CreateInfo.java +2 −1 Original line number Diff line number Diff line Loading @@ -336,7 +336,8 @@ public final class CreateInfo implements ICreateInfo { */ private final static String[] PROMOTED_FIELDS = new String[] { "android.graphics.drawable.VectorDrawable#mVectorState", "android.view.Choreographer#mLastFrameTimeNanos" "android.view.Choreographer#mLastFrameTimeNanos", "android.graphics.FontFamily#mBuilderPtr" }; /** Loading Loading
tools/layoutlib/bridge/src/android/graphics/FontFamily_Delegate.java +16 −8 Original line number Diff line number Diff line Loading @@ -248,14 +248,17 @@ public class FontFamily_Delegate { // ---- delegate methods ---- @LayoutlibDelegate /*package*/ static boolean addFont(FontFamily thisFontFamily, String path, int ttcIndex) { final FontFamily_Delegate delegate = getDelegate(thisFontFamily.mNativePtr); if (thisFontFamily.mBuilderPtr == 0) { throw new IllegalStateException("Unable to call addFont after freezing."); } final FontFamily_Delegate delegate = getDelegate(thisFontFamily.mBuilderPtr); return delegate != null && delegate.addFont(path, ttcIndex); } // ---- native methods ---- @LayoutlibDelegate /*package*/ static long nCreateFamily(String lang, int variant) { /*package*/ static long nInitBuilder(String lang, int variant) { // TODO: support lang. This is required for japanese locale. FontFamily_Delegate delegate = new FontFamily_Delegate(); // variant can be 0, 1 or 2. Loading @@ -269,6 +272,11 @@ public class FontFamily_Delegate { return sManager.addNewDelegate(delegate); } @LayoutlibDelegate /*package*/ static long nCreateFamily(long builderPtr) { return builderPtr; } @LayoutlibDelegate /*package*/ static void nUnrefFamily(long nativePtr) { // Removing the java reference for the object doesn't mean that it's freed for garbage Loading @@ -277,22 +285,22 @@ public class FontFamily_Delegate { } @LayoutlibDelegate /*package*/ static boolean nAddFont(long nativeFamily, ByteBuffer font, int ttcIndex) { /*package*/ static boolean nAddFont(long builderPtr, ByteBuffer font, int ttcIndex) { assert false : "The only client of this method has been overriden."; return false; } @LayoutlibDelegate /*package*/ static boolean nAddFontWeightStyle(long nativeFamily, ByteBuffer font, /*package*/ static boolean nAddFontWeightStyle(long builderPtr, ByteBuffer font, int ttcIndex, List<FontListParser.Axis> listOfAxis, int weight, boolean isItalic) { assert false : "The only client of this method has been overriden."; return false; } static boolean addFont(long nativeFamily, final String path, final int weight, static boolean addFont(long builderPtr, final String path, final int weight, final boolean isItalic) { final FontFamily_Delegate delegate = getDelegate(nativeFamily); final FontFamily_Delegate delegate = getDelegate(builderPtr); if (delegate != null) { if (sFontLocation == null) { delegate.mPostInitRunnables.add(() -> delegate.addFont(path, weight, isItalic)); Loading @@ -304,8 +312,8 @@ public class FontFamily_Delegate { } @LayoutlibDelegate /*package*/ static boolean nAddFontFromAsset(long nativeFamily, AssetManager mgr, String path) { FontFamily_Delegate ffd = sManager.getDelegate(nativeFamily); /*package*/ static boolean nAddFontFromAsset(long builderPtr, AssetManager mgr, String path) { FontFamily_Delegate ffd = sManager.getDelegate(builderPtr); if (ffd == null) { return false; } Loading
tools/layoutlib/bridge/src/android/graphics/Typeface_Delegate.java +2 −1 Original line number Diff line number Diff line Loading @@ -212,9 +212,10 @@ public final class Typeface_Delegate { Map<String, ByteBuffer> bufferForPath) { FontFamily fontFamily = new FontFamily(family.lang, family.variant); for (FontListParser.Font font : family.fonts) { FontFamily_Delegate.addFont(fontFamily.mNativePtr, font.fontName, font.weight, FontFamily_Delegate.addFont(fontFamily.mBuilderPtr, font.fontName, font.weight, font.isItalic); } fontFamily.freeze(); return fontFamily; } Loading
tools/layoutlib/create/src/com/android/tools/layoutlib/create/CreateInfo.java +2 −1 Original line number Diff line number Diff line Loading @@ -336,7 +336,8 @@ public final class CreateInfo implements ICreateInfo { */ private final static String[] PROMOTED_FIELDS = new String[] { "android.graphics.drawable.VectorDrawable#mVectorState", "android.view.Choreographer#mLastFrameTimeNanos" "android.view.Choreographer#mLastFrameTimeNanos", "android.graphics.FontFamily#mBuilderPtr" }; /** Loading