diff options
| author | Raph Levien <raph@google.com> | 2014-01-30 16:06:28 -0800 |
|---|---|---|
| committer | Raph Levien <raph@google.com> | 2014-05-12 10:41:42 -0700 |
| commit | 1a73f732f91e97c9c66b808c245ddda36a10e987 (patch) | |
| tree | 746813bccc7417446dc7e7590bfdd24c5f96dc7e /core/jni/android/graphics/FontFamily.cpp | |
| parent | e2b2514342448b97d7658dd4920b339a5239274c (diff) | |
| download | frameworks_base-1a73f732f91e97c9c66b808c245ddda36a10e987.zip frameworks_base-1a73f732f91e97c9c66b808c245ddda36a10e987.tar.gz frameworks_base-1a73f732f91e97c9c66b808c245ddda36a10e987.tar.bz2 | |
Start of Minikin integration
This is the current state of the Minikin integration. All changes are
hidden behind USE_MINIKIN #ifdef, so it should be safe to apply. To
play with the Minikin branch, set this in your BoardConfig.mk .
This change also merges in 64-bit changes that were happenening in
parallel.
Change-Id: Idd94553bcbe324c5875d0ff06495c966c3e95b7f
Diffstat (limited to 'core/jni/android/graphics/FontFamily.cpp')
| -rw-r--r-- | core/jni/android/graphics/FontFamily.cpp | 75 |
1 files changed, 75 insertions, 0 deletions
diff --git a/core/jni/android/graphics/FontFamily.cpp b/core/jni/android/graphics/FontFamily.cpp new file mode 100644 index 0000000..5782312 --- /dev/null +++ b/core/jni/android/graphics/FontFamily.cpp @@ -0,0 +1,75 @@ +/* + * Copyright (C) 2014 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 "JNIHelp.h" +#include <android_runtime/AndroidRuntime.h> + +#include "SkTypeface.h" +#include "GraphicsJNI.h" +#include <ScopedPrimitiveArray.h> +#include <ScopedUtfChars.h> + +#ifdef USE_MINIKIN +#include <minikin/FontFamily.h> +#include "MinikinSkia.h" +#endif + +namespace android { + +static jlong FontFamily_create(JNIEnv* env, jobject clazz) { +#ifdef USE_MINIKIN + return (jlong)new FontFamily(); +#else + return 0; +#endif +} + +static void FontFamily_destroy(JNIEnv* env, jobject clazz, jlong ptr) { + // TODO: work out lifetime issues +} + +static jboolean FontFamily_addFont(JNIEnv* env, jobject clazz, jlong familyPtr, jstring path) { +#ifdef USE_MINIKIN + NPE_CHECK_RETURN_ZERO(env, path); + ScopedUtfChars str(env, path); + ALOGD("addFont %s", str.c_str()); + SkTypeface* face = SkTypeface::CreateFromFile(str.c_str()); + MinikinFont* minikinFont = new MinikinFontSkia(face); + FontFamily* fontFamily = (FontFamily*)familyPtr; + return fontFamily->addFont(minikinFont); +#else + return false; +#endif +} + +/////////////////////////////////////////////////////////////////////////////// + +static JNINativeMethod gFontFamilyMethods[] = { + { "nCreateFamily", "()J", (void*)FontFamily_create }, + { "nDestroyFamily", "(J)V", (void*)FontFamily_destroy }, + { "nAddFont", "(JLjava/lang/String;)Z", (void*)FontFamily_addFont }, +}; + +int register_android_graphics_FontFamily(JNIEnv* env) +{ + return android::AndroidRuntime::registerNativeMethods(env, + "android/graphics/FontFamily", + gFontFamilyMethods, NELEM(gFontFamilyMethods)); +} + +} |
