diff options
author | Raph Levien <raph@google.com> | 2014-05-15 02:03:01 +0000 |
---|---|---|
committer | Android (Google) Code Review <android-gerrit@google.com> | 2014-05-15 02:03:05 +0000 |
commit | 2836c4722a156ec78d7f4101b394885a354f5dd6 (patch) | |
tree | 2953f5ef47ee1847afa55129782bde86b73e1601 /graphics | |
parent | fe4c1e225d147fe9cb5d7c121b7d6d11a312844e (diff) | |
parent | 1a73f732f91e97c9c66b808c245ddda36a10e987 (diff) | |
download | frameworks_base-2836c4722a156ec78d7f4101b394885a354f5dd6.zip frameworks_base-2836c4722a156ec78d7f4101b394885a354f5dd6.tar.gz frameworks_base-2836c4722a156ec78d7f4101b394885a354f5dd6.tar.bz2 |
Merge "Start of Minikin integration"
Diffstat (limited to 'graphics')
-rw-r--r-- | graphics/java/android/graphics/FontFamily.java | 40 | ||||
-rw-r--r-- | graphics/java/android/graphics/Paint.java | 24 | ||||
-rw-r--r-- | graphics/java/android/graphics/Typeface.java | 18 |
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 457b3ea..bdef404 100644 --- a/graphics/java/android/graphics/Paint.java +++ b/graphics/java/android/graphics/Paint.java @@ -1655,12 +1655,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; @@ -1737,12 +1737,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; @@ -1832,13 +1832,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); @@ -1963,13 +1963,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); @@ -2234,19 +2234,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); } |