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_GRAPHICS_TYPEFACE_IMPL_H_ 19#define _ANDROID_GRAPHICS_TYPEFACE_IMPL_H_ 20 21#include "jni.h" // for jlong, eventually remove 22#include "SkTypeface.h" 23#include <androidfw/AssetManager.h> 24 25#include <minikin/FontCollection.h> 26 27namespace android { 28 29struct TypefaceImpl { 30 FontCollection *fFontCollection; 31 32 // style used for constructing and querying Typeface objects 33 SkTypeface::Style fSkiaStyle; 34 // base weight in CSS-style units, 100..900 35 int fBaseWeight; 36 37 // resolved style actually used for rendering 38 FontStyle fStyle; 39}; 40 41// Note: it would be cleaner if the following functions were member 42// functions (static or otherwise) of the TypefaceImpl class. However, 43// that can't be easily accommodated in the case where TypefaceImpl 44// is just a pointer to SkTypeface, in the non-USE_MINIKIN case. 45// TODO: when #ifdef USE_MINIKIN is removed, move to member functions. 46 47TypefaceImpl* TypefaceImpl_resolveDefault(TypefaceImpl* src); 48 49TypefaceImpl* TypefaceImpl_createFromTypeface(TypefaceImpl* src, SkTypeface::Style style); 50 51TypefaceImpl* TypefaceImpl_createWeightAlias(TypefaceImpl* src, int baseweight); 52 53// When we remove the USE_MINIKIN ifdef, probably a good idea to move the casting 54// (from jlong to FontFamily*) to the caller in Typeface.cpp. 55TypefaceImpl* TypefaceImpl_createFromFamilies(const jlong* families, size_t size); 56 57void TypefaceImpl_unref(TypefaceImpl* face); 58 59int TypefaceImpl_getStyle(TypefaceImpl* face); 60 61void TypefaceImpl_setDefault(TypefaceImpl* face); 62 63} 64 65#endif // _ANDROID_GRAPHICS_TYPEFACE_IMPL_H_ 66