Loading core/jni/android/graphics/FontFamily.cpp +6 −3 Original line number Diff line number Diff line Loading @@ -39,8 +39,11 @@ static jlong FontFamily_create(JNIEnv* env, jobject clazz) { #endif } static void FontFamily_destroy(JNIEnv* env, jobject clazz, jlong ptr) { // TODO: work out lifetime issues static void FontFamily_unref(JNIEnv* env, jobject clazz, jlong familyPtr) { #ifdef USE_MINIKIN FontFamily* fontFamily = reinterpret_cast<FontFamily*>(familyPtr); fontFamily->Unref(); #endif } static jboolean FontFamily_addFont(JNIEnv* env, jobject clazz, jlong familyPtr, jstring path) { Loading @@ -65,7 +68,7 @@ static jboolean FontFamily_addFont(JNIEnv* env, jobject clazz, jlong familyPtr, static JNINativeMethod gFontFamilyMethods[] = { { "nCreateFamily", "()J", (void*)FontFamily_create }, { "nDestroyFamily", "(J)V", (void*)FontFamily_destroy }, { "nUnrefFamily", "(J)V", (void*)FontFamily_unref }, { "nAddFont", "(JLjava/lang/String;)Z", (void*)FontFamily_addFont }, }; Loading core/jni/android/graphics/TypefaceImpl.cpp +8 −1 Original line number Diff line number Diff line Loading @@ -74,13 +74,16 @@ static FontCollection *makeFontCollection() { if (skFace != NULL) { MinikinFont *font = new MinikinFontSkia(skFace); family->addFont(font); font->Unref(); } else { ALOGE("failed to create font %s", fn); } } typefaces.push_back(family); return new FontCollection(typefaces); FontCollection *result = new FontCollection(typefaces); family->Unref(); return result; } static void getDefaultTypefaceOnce() { Loading Loading @@ -108,6 +111,7 @@ TypefaceImpl* TypefaceImpl_createFromTypeface(TypefaceImpl* src, SkTypeface::Sty TypefaceImpl* result = new TypefaceImpl; if (result != 0) { result->fFontCollection = resolvedFace->fFontCollection; result->fFontCollection->Ref(); result->fStyle = styleFromSkiaStyle(style); } return result; Loading @@ -121,9 +125,11 @@ static TypefaceImpl* createFromSkTypeface(SkTypeface* typeface) { std::vector<FontFamily *> typefaces; FontFamily* family = new FontFamily(); family->addFont(minikinFont); minikinFont->Unref(); typefaces.push_back(family); TypefaceImpl* result = new TypefaceImpl; result->fFontCollection = new FontCollection(typefaces); family->Unref(); result->fStyle = FontStyle(); // TODO: improve return result; } Loading Loading @@ -165,6 +171,7 @@ TypefaceImpl* TypefaceImpl_createFromFamilies(const jlong* families, size_t size } void TypefaceImpl_unref(TypefaceImpl* face) { face->fFontCollection->Unref(); delete face; } Loading graphics/java/android/graphics/FontFamily.java +10 −2 Original line number Diff line number Diff line Loading @@ -36,13 +36,21 @@ public class FontFamily { throw new RuntimeException(); } } // TODO: finalization @Override protected void finalize() throws Throwable { try { nUnrefFamily(mNativePtr); } finally { super.finalize(); } } public boolean addFont(File path) { return nAddFont(mNativePtr, path.getAbsolutePath()); } static native long nCreateFamily(); static native void nDestroyFamily(long nativePtr); static native void nUnrefFamily(long nativePtr); static native boolean nAddFont(long nativeFamily, String path); } Loading
core/jni/android/graphics/FontFamily.cpp +6 −3 Original line number Diff line number Diff line Loading @@ -39,8 +39,11 @@ static jlong FontFamily_create(JNIEnv* env, jobject clazz) { #endif } static void FontFamily_destroy(JNIEnv* env, jobject clazz, jlong ptr) { // TODO: work out lifetime issues static void FontFamily_unref(JNIEnv* env, jobject clazz, jlong familyPtr) { #ifdef USE_MINIKIN FontFamily* fontFamily = reinterpret_cast<FontFamily*>(familyPtr); fontFamily->Unref(); #endif } static jboolean FontFamily_addFont(JNIEnv* env, jobject clazz, jlong familyPtr, jstring path) { Loading @@ -65,7 +68,7 @@ static jboolean FontFamily_addFont(JNIEnv* env, jobject clazz, jlong familyPtr, static JNINativeMethod gFontFamilyMethods[] = { { "nCreateFamily", "()J", (void*)FontFamily_create }, { "nDestroyFamily", "(J)V", (void*)FontFamily_destroy }, { "nUnrefFamily", "(J)V", (void*)FontFamily_unref }, { "nAddFont", "(JLjava/lang/String;)Z", (void*)FontFamily_addFont }, }; Loading
core/jni/android/graphics/TypefaceImpl.cpp +8 −1 Original line number Diff line number Diff line Loading @@ -74,13 +74,16 @@ static FontCollection *makeFontCollection() { if (skFace != NULL) { MinikinFont *font = new MinikinFontSkia(skFace); family->addFont(font); font->Unref(); } else { ALOGE("failed to create font %s", fn); } } typefaces.push_back(family); return new FontCollection(typefaces); FontCollection *result = new FontCollection(typefaces); family->Unref(); return result; } static void getDefaultTypefaceOnce() { Loading Loading @@ -108,6 +111,7 @@ TypefaceImpl* TypefaceImpl_createFromTypeface(TypefaceImpl* src, SkTypeface::Sty TypefaceImpl* result = new TypefaceImpl; if (result != 0) { result->fFontCollection = resolvedFace->fFontCollection; result->fFontCollection->Ref(); result->fStyle = styleFromSkiaStyle(style); } return result; Loading @@ -121,9 +125,11 @@ static TypefaceImpl* createFromSkTypeface(SkTypeface* typeface) { std::vector<FontFamily *> typefaces; FontFamily* family = new FontFamily(); family->addFont(minikinFont); minikinFont->Unref(); typefaces.push_back(family); TypefaceImpl* result = new TypefaceImpl; result->fFontCollection = new FontCollection(typefaces); family->Unref(); result->fStyle = FontStyle(); // TODO: improve return result; } Loading Loading @@ -165,6 +171,7 @@ TypefaceImpl* TypefaceImpl_createFromFamilies(const jlong* families, size_t size } void TypefaceImpl_unref(TypefaceImpl* face) { face->fFontCollection->Unref(); delete face; } Loading
graphics/java/android/graphics/FontFamily.java +10 −2 Original line number Diff line number Diff line Loading @@ -36,13 +36,21 @@ public class FontFamily { throw new RuntimeException(); } } // TODO: finalization @Override protected void finalize() throws Throwable { try { nUnrefFamily(mNativePtr); } finally { super.finalize(); } } public boolean addFont(File path) { return nAddFont(mNativePtr, path.getAbsolutePath()); } static native long nCreateFamily(); static native void nDestroyFamily(long nativePtr); static native void nUnrefFamily(long nativePtr); static native boolean nAddFont(long nativeFamily, String path); }