summaryrefslogtreecommitdiffstats
path: root/graphics
diff options
context:
space:
mode:
authorRaph Levien <raph@google.com>2014-01-30 16:06:28 -0800
committerRaph Levien <raph@google.com>2014-05-12 10:41:42 -0700
commit1a73f732f91e97c9c66b808c245ddda36a10e987 (patch)
tree746813bccc7417446dc7e7590bfdd24c5f96dc7e /graphics
parente2b2514342448b97d7658dd4920b339a5239274c (diff)
downloadframeworks_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 'graphics')
-rw-r--r--graphics/java/android/graphics/FontFamily.java40
-rw-r--r--graphics/java/android/graphics/Paint.java24
-rw-r--r--graphics/java/android/graphics/Typeface.java18
3 files changed, 70 insertions, 12 deletions
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<res; i++) {
widths[i] *= mInvCompatScaling;
@@ -1768,12 +1768,12 @@ public class Paint {
return 0;
}
if (!mHasCompatScaling) {
- return native_getTextWidths(mNativePaint, text, start, end, mBidiFlags, widths);
+ return native_getTextWidths(mNativePaint, mNativeTypeface, text, start, end, mBidiFlags, widths);
}
final float oldSize = getTextSize();
setTextSize(oldSize*mCompatScaling);
- int res = native_getTextWidths(mNativePaint, text, start, end, mBidiFlags, widths);
+ int res = native_getTextWidths(mNativePaint, mNativeTypeface, text, start, end, mBidiFlags, widths);
setTextSize(oldSize);
for (int i=0; i<res; i++) {
widths[i] *= mInvCompatScaling;
@@ -1863,13 +1863,13 @@ public class Paint {
return 0f;
}
if (!mHasCompatScaling) {
- return native_getTextRunAdvances(mNativePaint, chars, index, count,
+ return native_getTextRunAdvances(mNativePaint, mNativeTypeface, chars, index, count,
contextIndex, contextCount, flags, advances, advancesIndex);
}
final float oldSize = getTextSize();
setTextSize(oldSize * mCompatScaling);
- float res = native_getTextRunAdvances(mNativePaint, chars, index, count,
+ float res = native_getTextRunAdvances(mNativePaint, mNativeTypeface, chars, index, count,
contextIndex, contextCount, flags, advances, advancesIndex);
setTextSize(oldSize);
@@ -1994,13 +1994,13 @@ public class Paint {
}
if (!mHasCompatScaling) {
- return native_getTextRunAdvances(mNativePaint, text, start, end,
+ return native_getTextRunAdvances(mNativePaint, mNativeTypeface, text, start, end,
contextStart, contextEnd, flags, advances, advancesIndex);
}
final float oldSize = getTextSize();
setTextSize(oldSize * mCompatScaling);
- float totalAdvance = native_getTextRunAdvances(mNativePaint, text, start, end,
+ float totalAdvance = native_getTextRunAdvances(mNativePaint, mNativeTypeface, text, start, end,
contextStart, contextEnd, flags, advances, advancesIndex);
setTextSize(oldSize);
@@ -2265,19 +2265,19 @@ public class Paint {
private static native void native_setTextLocale(long native_object,
String locale);
- private static native int native_getTextWidths(long native_object,
+ private static native int native_getTextWidths(long native_object, long native_typeface,
char[] text, int index, int count, int bidiFlags, float[] widths);
- private static native int native_getTextWidths(long native_object,
+ private static native int native_getTextWidths(long native_object, long native_typeface,
String text, int start, int end, int bidiFlags, float[] widths);
private static native int native_getTextGlyphs(long native_object,
String text, int start, int end, int contextStart, int contextEnd,
int flags, char[] glyphs);
- private static native float native_getTextRunAdvances(long native_object,
+ private static native float native_getTextRunAdvances(long native_object, long native_typeface,
char[] text, int index, int count, int contextIndex, int contextCount,
int flags, float[] advances, int advancesIndex);
- private static native float native_getTextRunAdvances(long native_object,
+ private static native float native_getTextRunAdvances(long native_object, long native_typeface,
String text, int start, int end, int contextStart, int contextEnd,
int flags, float[] advances, int advancesIndex);
diff --git a/graphics/java/android/graphics/Typeface.java b/graphics/java/android/graphics/Typeface.java
index 73e0e8d..4b95fcd 100644
--- a/graphics/java/android/graphics/Typeface.java
+++ b/graphics/java/android/graphics/Typeface.java
@@ -17,6 +17,7 @@
package android.graphics;
import android.content.res.AssetManager;
+import android.util.Log;
import android.util.SparseArray;
import android.util.LongSparseArray;
@@ -173,6 +174,22 @@ public class Typeface {
return new Typeface(nativeCreateFromFile(path));
}
+ /**
+ * Create a new typeface from an array of font families.
+ *
+ * @param families array of font families
+ * @hide
+ */
+ public static Typeface createFromFamilies(FontFamily[] families) {
+ long[] ptrArray = new long[families.length];
+ Log.d("Minikin", "# of families: " + families.length);
+ for (int i = 0; i < families.length; i++) {
+ Log.d("Minikin", "family ptr: " + families[i].mNativePtr);
+ ptrArray[i] = families[i].mNativePtr;
+ }
+ return new Typeface(nativeCreateFromArray(ptrArray));
+ }
+
// don't allow clients to call this directly
private Typeface(long ni) {
if (ni == 0) {
@@ -234,4 +251,5 @@ public class Typeface {
private static native int nativeGetStyle(long native_instance);
private static native long nativeCreateFromAsset(AssetManager mgr, String path);
private static native long nativeCreateFromFile(String path);
+ private static native long nativeCreateFromArray(long[] familyArray);
}