From 1a73f732f91e97c9c66b808c245ddda36a10e987 Mon Sep 17 00:00:00 2001 From: Raph Levien Date: Thu, 30 Jan 2014 16:06:28 -0800 Subject: 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 --- graphics/java/android/graphics/FontFamily.java | 40 ++++++++++++++++++++++++++ graphics/java/android/graphics/Paint.java | 24 ++++++++-------- graphics/java/android/graphics/Typeface.java | 18 ++++++++++++ 3 files changed, 70 insertions(+), 12 deletions(-) create mode 100644 graphics/java/android/graphics/FontFamily.java (limited to 'graphics') diff --git a/graphics/java/android/graphics/FontFamily.java b/graphics/java/android/graphics/FontFamily.java new file mode 100644 index 0000000..afa8706 --- /dev/null +++ b/graphics/java/android/graphics/FontFamily.java @@ -0,0 +1,40 @@ +/* + * 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. + */ + +package android.graphics; + +import java.io.File; + +/** + * A family of typefaces with different styles. + * + * @hide + */ +public class FontFamily { + public long mNativePtr; + public FontFamily() { + mNativePtr = nCreateFamily(); + } + // TODO: finalization + + public boolean addFont(File path) { + return nAddFont(mNativePtr, path.getAbsolutePath()); + } + + static native long nCreateFamily(); + static native void nDestroyFamily(long nativePtr); + static native boolean nAddFont(long nativeFamily, String path); +} diff --git a/graphics/java/android/graphics/Paint.java b/graphics/java/android/graphics/Paint.java index 1e1128e..af8b9d9 100644 --- a/graphics/java/android/graphics/Paint.java +++ b/graphics/java/android/graphics/Paint.java @@ -1686,12 +1686,12 @@ public class Paint { return 0; } if (!mHasCompatScaling) { - return native_getTextWidths(mNativePaint, text, index, count, mBidiFlags, widths); + return native_getTextWidths(mNativePaint, mNativeTypeface, text, index, count, mBidiFlags, widths); } final float oldSize = getTextSize(); setTextSize(oldSize*mCompatScaling); - int res = native_getTextWidths(mNativePaint, text, index, count, mBidiFlags, widths); + int res = native_getTextWidths(mNativePaint, mNativeTypeface, text, index, count, mBidiFlags, widths); setTextSize(oldSize); for (int i=0; i