TypefaceImpl.h revision 9a5b61ccc83303ceeec2059f58c1977af9faa9e3
1/* 2 * Copyright (C) 2013 The Android Open Source Project 3 * 4 * Licensed under the Apache License, Version 2.0 (the "License"); 5 * you may not use this file except in compliance with the License. 6 * You may obtain a copy of the License at 7 * 8 * http://www.apache.org/licenses/LICENSE-2.0 9 * 10 * Unless required by applicable law or agreed to in writing, software 11 * distributed under the License is distributed on an "AS IS" BASIS, 12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 * See the License for the specific language governing permissions and 14 * limitations under the License. 15 */ 16 17 18#ifndef ANDROID_TYPEFACE_IMPL_H 19#define ANDROID_TYPEFACE_IMPL_H 20 21#include "jni.h" // for jlong, eventually remove 22#include "SkTypeface.h" 23#include <androidfw/AssetManager.h> 24 25#ifdef USE_MINIKIN 26#include <minikin/FontCollection.h> 27#endif 28 29namespace android { 30 31#ifdef USE_MINIKIN 32struct TypefaceImpl { 33 FontCollection *fFontCollection; 34 FontStyle fStyle; 35}; 36 37// Note: it would be cleaner if the following functions were member 38// functions (static or otherwise) of the TypefaceImpl class. However, 39// that can't be easily accommodated in the case where TypefaceImpl 40// is just a pointer to SkTypeface, in the non-USE_MINIKIN case. 41// TODO: when #ifdef USE_MINIKIN is removed, move to member functions. 42 43TypefaceImpl* TypefaceImpl_resolveDefault(TypefaceImpl* src); 44#else 45typedef SkTypeface TypefaceImpl; 46#endif 47 48TypefaceImpl* TypefaceImpl_createFromTypeface(TypefaceImpl* src, SkTypeface::Style style); 49 50TypefaceImpl* TypefaceImpl_createFromName(const char* name, SkTypeface::Style style); 51 52TypefaceImpl* TypefaceImpl_createFromFile(const char* filename); 53 54TypefaceImpl* TypefaceImpl_createFromAsset(Asset* asset); 55 56// When we remove the USE_MINIKIN ifdef, probably a good idea to move the casting 57// (from jlong to FontFamily*) to the caller in Typeface.cpp. 58TypefaceImpl* TypefaceImpl_createFromFamilies(const jlong* families, size_t size); 59 60void TypefaceImpl_unref(TypefaceImpl* face); 61 62int TypefaceImpl_getStyle(TypefaceImpl* face); 63 64void TypefaceImpl_setDefault(TypefaceImpl* face); 65 66} 67 68#endif // ANDROID_TYPEFACE_IMPL_H