Merge "Fix broken delegates for FontFamily and PathParser" into nyc-dev

This commit is contained in:
Diego Perez
2016-04-12 16:24:21 +00:00
committed by Android (Google) Code Review
3 changed files with 21 additions and 13 deletions

View File

@@ -245,6 +245,13 @@ public class FontFamily_Delegate {
return sFontLocation; return sFontLocation;
} }
// ---- delegate methods ----
@LayoutlibDelegate
/*package*/ static boolean addFont(FontFamily thisFontFamily, String path, int ttcIndex) {
final FontFamily_Delegate delegate = getDelegate(thisFontFamily.mNativePtr);
return delegate != null && delegate.addFont(path, ttcIndex);
}
// ---- native methods ---- // ---- native methods ----
@LayoutlibDelegate @LayoutlibDelegate
@@ -270,16 +277,8 @@ public class FontFamily_Delegate {
} }
@LayoutlibDelegate @LayoutlibDelegate
/*package*/ static boolean nAddFont(long nativeFamily, final String path, int ttcIndex) { /*package*/ static boolean nAddFont(long nativeFamily, ByteBuffer font, int ttcIndex) {
// FIXME: support ttc fonts. Hack JRE?? assert false : "The only client of this method has been overriden.";
final FontFamily_Delegate delegate = getDelegate(nativeFamily);
if (delegate != null) {
if (sFontLocation == null) {
delegate.mPostInitRunnables.add(() -> delegate.addFont(path));
return true;
}
return delegate.addFont(path);
}
return false; return false;
} }
@@ -390,6 +389,15 @@ public class FontFamily_Delegate {
mPostInitRunnables = null; mPostInitRunnables = null;
} }
private boolean addFont(final String path, int ttcIndex) {
// FIXME: support ttc fonts. Hack JRE??
if (sFontLocation == null) {
mPostInitRunnables.add(() -> addFont(path));
return true;
}
return addFont(path);
}
private boolean addFont(@NonNull String path) { private boolean addFont(@NonNull String path) {
return addFont(path, DEFAULT_FONT_WEIGHT, path.endsWith(FONT_SUFFIX_ITALIC)); return addFont(path, DEFAULT_FONT_WEIGHT, path.endsWith(FONT_SUFFIX_ITALIC));
} }

View File

@@ -64,15 +64,14 @@ public class PathParser_Delegate {
} }
@LayoutlibDelegate @LayoutlibDelegate
/*package*/ static boolean nParseStringForPath(long pathPtr, @NonNull String pathString, int /*package*/ static void nParseStringForPath(long pathPtr, @NonNull String pathString, int
stringLength) { stringLength) {
Path_Delegate path_delegate = Path_Delegate.getDelegate(pathPtr); Path_Delegate path_delegate = Path_Delegate.getDelegate(pathPtr);
if (path_delegate == null) { if (path_delegate == null) {
return false; return;
} }
assert pathString.length() == stringLength; assert pathString.length() == stringLength;
PathDataNode.nodesToPath(createNodesFromPathData(pathString), path_delegate); PathDataNode.nodesToPath(createNodesFromPathData(pathString), path_delegate);
return true;
} }
@LayoutlibDelegate @LayoutlibDelegate

View File

@@ -192,6 +192,7 @@ public final class CreateInfo implements ICreateInfo {
"android.graphics.BitmapFactory#setDensityFromOptions", "android.graphics.BitmapFactory#setDensityFromOptions",
"android.graphics.drawable.AnimatedVectorDrawable$VectorDrawableAnimatorRT#useLastSeenTarget", "android.graphics.drawable.AnimatedVectorDrawable$VectorDrawableAnimatorRT#useLastSeenTarget",
"android.graphics.drawable.GradientDrawable#buildRing", "android.graphics.drawable.GradientDrawable#buildRing",
"android.graphics.FontFamily#addFont",
"android.graphics.Typeface#getSystemFontConfigLocation", "android.graphics.Typeface#getSystemFontConfigLocation",
"android.graphics.Typeface#makeFamilyFromParsed", "android.graphics.Typeface#makeFamilyFromParsed",
"android.os.Handler#sendMessageAtTime", "android.os.Handler#sendMessageAtTime",