Loading api/current.txt +11 −0 Original line number Diff line number Diff line Loading @@ -15211,6 +15211,17 @@ package android.graphics.fonts { method public android.graphics.fonts.Font.Builder setWeight(int); } public class FontFamily { method public android.graphics.fonts.Font getFont(int); method public int getFontCount(); } public static class FontFamily.Builder { ctor public FontFamily.Builder(android.graphics.fonts.Font); method public android.graphics.fonts.FontFamily.Builder addFont(android.graphics.fonts.Font); method public android.graphics.fonts.FontFamily build(); } public final class FontVariationAxis { ctor public FontVariationAxis(java.lang.String, float); method public static android.graphics.fonts.FontVariationAxis[] fromFontVariationSettings(java.lang.String); core/jni/Android.bp +1 −0 Original line number Diff line number Diff line Loading @@ -155,6 +155,7 @@ cc_library_shared { "android/graphics/Utils.cpp", "android/graphics/YuvToJpegEncoder.cpp", "android/graphics/fonts/Font.cpp", "android/graphics/fonts/FontFamily.cpp", "android/graphics/pdf/PdfDocument.cpp", "android/graphics/pdf/PdfEditor.cpp", "android/graphics/pdf/PdfRenderer.cpp", Loading core/jni/AndroidRuntime.cpp +2 −0 Original line number Diff line number Diff line Loading @@ -141,6 +141,7 @@ extern int register_android_graphics_SurfaceTexture(JNIEnv* env); extern int register_android_graphics_drawable_AnimatedVectorDrawable(JNIEnv* env); extern int register_android_graphics_drawable_VectorDrawable(JNIEnv* env); extern int register_android_graphics_fonts_Font(JNIEnv* env); extern int register_android_graphics_fonts_FontFamily(JNIEnv* env); extern int register_android_graphics_pdf_PdfDocument(JNIEnv* env); extern int register_android_graphics_pdf_PdfEditor(JNIEnv* env); extern int register_android_graphics_pdf_PdfRenderer(JNIEnv* env); Loading Loading @@ -1408,6 +1409,7 @@ static const RegJNIRec gRegJNI[] = { REG_JNI(register_android_graphics_drawable_AnimatedVectorDrawable), REG_JNI(register_android_graphics_drawable_VectorDrawable), REG_JNI(register_android_graphics_fonts_Font), REG_JNI(register_android_graphics_fonts_FontFamily), REG_JNI(register_android_graphics_pdf_PdfDocument), REG_JNI(register_android_graphics_pdf_PdfEditor), REG_JNI(register_android_graphics_pdf_PdfRenderer), Loading core/jni/android/graphics/fonts/FontFamily.cpp 0 → 100644 +90 −0 Original line number Diff line number Diff line /* * Copyright (C) 2018 The Android Open Source Project * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ #define LOG_TAG "Minikin" #include <nativehelper/JNIHelp.h> #include <core_jni_helpers.h> #include "FontUtils.h" #include <minikin/FontFamily.h> #include <memory> namespace android { struct NativeFamilyBuilder { std::vector<minikin::Font> fonts; }; static inline NativeFamilyBuilder* toBuilder(jlong ptr) { return reinterpret_cast<NativeFamilyBuilder*>(ptr); } static inline FontWrapper* toFontWrapper(jlong ptr) { return reinterpret_cast<FontWrapper*>(ptr); } static void releaseFontFamily(jlong family) { delete reinterpret_cast<FontFamilyWrapper*>(family); } // Regular JNI static jlong FontFamily_Builder_initBuilder(JNIEnv*, jobject) { return reinterpret_cast<jlong>(new NativeFamilyBuilder()); } // Critical Native static void FontFamily_Builder_addFont(jlong builderPtr, jlong fontPtr) { toBuilder(builderPtr)->fonts.push_back(toFontWrapper(fontPtr)->font); } // Regular JNI static jlong FontFamily_Builder_build(JNIEnv* env, jobject clazz, jlong builderPtr) { std::unique_ptr<NativeFamilyBuilder> builder(toBuilder(builderPtr)); std::shared_ptr<minikin::FontFamily> family = std::make_shared<minikin::FontFamily>(std::move(builder->fonts)); if (family->getCoverage().length() == 0) { // No coverage means minikin rejected given font for some reasons. jniThrowException(env, "java/lang/IllegalArgumentException", "Failed to create internal object. maybe invalid font data"); return 0; } return reinterpret_cast<jlong>(new FontFamilyWrapper(std::move(family))); } // CriticalNative static jlong FontFamily_Builder_GetReleaseFunc() { return reinterpret_cast<jlong>(releaseFontFamily); } /////////////////////////////////////////////////////////////////////////////// static const JNINativeMethod gFontFamilyBuilderMethods[] = { { "nInitBuilder", "()J", (void*) FontFamily_Builder_initBuilder }, { "nAddFont", "(JJ)V", (void*) FontFamily_Builder_addFont }, { "nBuild", "(J)J", (void*) FontFamily_Builder_build }, { "nGetReleaseNativeFamily", "()J", (void*) FontFamily_Builder_GetReleaseFunc }, }; int register_android_graphics_fonts_FontFamily(JNIEnv* env) { return RegisterMethodsOrDie(env, "android/graphics/fonts/FontFamily$Builder", gFontFamilyBuilderMethods, NELEM(gFontFamilyBuilderMethods)); } } graphics/java/android/graphics/fonts/Font.java +5 −0 Original line number Diff line number Diff line Loading @@ -469,4 +469,9 @@ public class Font { public long getNativePtr() { return mNativePtr; } @Override public String toString() { return "Font {weight=" + mWeight + ", italic=" + mItalic + "}"; } } Loading
api/current.txt +11 −0 Original line number Diff line number Diff line Loading @@ -15211,6 +15211,17 @@ package android.graphics.fonts { method public android.graphics.fonts.Font.Builder setWeight(int); } public class FontFamily { method public android.graphics.fonts.Font getFont(int); method public int getFontCount(); } public static class FontFamily.Builder { ctor public FontFamily.Builder(android.graphics.fonts.Font); method public android.graphics.fonts.FontFamily.Builder addFont(android.graphics.fonts.Font); method public android.graphics.fonts.FontFamily build(); } public final class FontVariationAxis { ctor public FontVariationAxis(java.lang.String, float); method public static android.graphics.fonts.FontVariationAxis[] fromFontVariationSettings(java.lang.String);
core/jni/Android.bp +1 −0 Original line number Diff line number Diff line Loading @@ -155,6 +155,7 @@ cc_library_shared { "android/graphics/Utils.cpp", "android/graphics/YuvToJpegEncoder.cpp", "android/graphics/fonts/Font.cpp", "android/graphics/fonts/FontFamily.cpp", "android/graphics/pdf/PdfDocument.cpp", "android/graphics/pdf/PdfEditor.cpp", "android/graphics/pdf/PdfRenderer.cpp", Loading
core/jni/AndroidRuntime.cpp +2 −0 Original line number Diff line number Diff line Loading @@ -141,6 +141,7 @@ extern int register_android_graphics_SurfaceTexture(JNIEnv* env); extern int register_android_graphics_drawable_AnimatedVectorDrawable(JNIEnv* env); extern int register_android_graphics_drawable_VectorDrawable(JNIEnv* env); extern int register_android_graphics_fonts_Font(JNIEnv* env); extern int register_android_graphics_fonts_FontFamily(JNIEnv* env); extern int register_android_graphics_pdf_PdfDocument(JNIEnv* env); extern int register_android_graphics_pdf_PdfEditor(JNIEnv* env); extern int register_android_graphics_pdf_PdfRenderer(JNIEnv* env); Loading Loading @@ -1408,6 +1409,7 @@ static const RegJNIRec gRegJNI[] = { REG_JNI(register_android_graphics_drawable_AnimatedVectorDrawable), REG_JNI(register_android_graphics_drawable_VectorDrawable), REG_JNI(register_android_graphics_fonts_Font), REG_JNI(register_android_graphics_fonts_FontFamily), REG_JNI(register_android_graphics_pdf_PdfDocument), REG_JNI(register_android_graphics_pdf_PdfEditor), REG_JNI(register_android_graphics_pdf_PdfRenderer), Loading
core/jni/android/graphics/fonts/FontFamily.cpp 0 → 100644 +90 −0 Original line number Diff line number Diff line /* * Copyright (C) 2018 The Android Open Source Project * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ #define LOG_TAG "Minikin" #include <nativehelper/JNIHelp.h> #include <core_jni_helpers.h> #include "FontUtils.h" #include <minikin/FontFamily.h> #include <memory> namespace android { struct NativeFamilyBuilder { std::vector<minikin::Font> fonts; }; static inline NativeFamilyBuilder* toBuilder(jlong ptr) { return reinterpret_cast<NativeFamilyBuilder*>(ptr); } static inline FontWrapper* toFontWrapper(jlong ptr) { return reinterpret_cast<FontWrapper*>(ptr); } static void releaseFontFamily(jlong family) { delete reinterpret_cast<FontFamilyWrapper*>(family); } // Regular JNI static jlong FontFamily_Builder_initBuilder(JNIEnv*, jobject) { return reinterpret_cast<jlong>(new NativeFamilyBuilder()); } // Critical Native static void FontFamily_Builder_addFont(jlong builderPtr, jlong fontPtr) { toBuilder(builderPtr)->fonts.push_back(toFontWrapper(fontPtr)->font); } // Regular JNI static jlong FontFamily_Builder_build(JNIEnv* env, jobject clazz, jlong builderPtr) { std::unique_ptr<NativeFamilyBuilder> builder(toBuilder(builderPtr)); std::shared_ptr<minikin::FontFamily> family = std::make_shared<minikin::FontFamily>(std::move(builder->fonts)); if (family->getCoverage().length() == 0) { // No coverage means minikin rejected given font for some reasons. jniThrowException(env, "java/lang/IllegalArgumentException", "Failed to create internal object. maybe invalid font data"); return 0; } return reinterpret_cast<jlong>(new FontFamilyWrapper(std::move(family))); } // CriticalNative static jlong FontFamily_Builder_GetReleaseFunc() { return reinterpret_cast<jlong>(releaseFontFamily); } /////////////////////////////////////////////////////////////////////////////// static const JNINativeMethod gFontFamilyBuilderMethods[] = { { "nInitBuilder", "()J", (void*) FontFamily_Builder_initBuilder }, { "nAddFont", "(JJ)V", (void*) FontFamily_Builder_addFont }, { "nBuild", "(J)J", (void*) FontFamily_Builder_build }, { "nGetReleaseNativeFamily", "()J", (void*) FontFamily_Builder_GetReleaseFunc }, }; int register_android_graphics_fonts_FontFamily(JNIEnv* env) { return RegisterMethodsOrDie(env, "android/graphics/fonts/FontFamily$Builder", gFontFamilyBuilderMethods, NELEM(gFontFamilyBuilderMethods)); } }
graphics/java/android/graphics/fonts/Font.java +5 −0 Original line number Diff line number Diff line Loading @@ -469,4 +469,9 @@ public class Font { public long getNativePtr() { return mNativePtr; } @Override public String toString() { return "Font {weight=" + mWeight + ", italic=" + mItalic + "}"; } }