Typeface.h revision d154829cb15d61f1469f939d608e691256e2a765
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 "SkTypeface.h" 22 23#include <cutils/compiler.h> 24#include <minikin/FontCollection.h> 25#include <vector> 26#include <memory> 27 28namespace android { 29 30struct ANDROID_API Typeface { 31 std::shared_ptr<minikin::FontCollection> fFontCollection; 32 33 // style used for constructing and querying Typeface objects 34 SkTypeface::Style fSkiaStyle; 35 // base weight in CSS-style units, 100..900 36 int fBaseWeight; 37 38 // resolved style actually used for rendering 39 minikin::FontStyle fStyle; 40 41 static Typeface* resolveDefault(Typeface* src); 42 43 static Typeface* createFromTypeface(Typeface* src, SkTypeface::Style style); 44 45 static Typeface* createFromTypefaceWithStyle(Typeface* base, int weight, bool italic); 46 47 static Typeface* createFromTypefaceWithVariation(Typeface* src, 48 const std::vector<minikin::FontVariation>& variations); 49 50 static Typeface* createWeightAlias(Typeface* src, int baseweight); 51 52 static Typeface* createFromFamilies( 53 std::vector<std::shared_ptr<minikin::FontFamily>>&& families, 54 int weight, int italic); 55 56 static void setDefault(Typeface* face); 57 58 // Sets roboto font as the default typeface for testing purpose. 59 static void setRobotoTypefaceForTest(); 60}; 61 62} 63 64#endif // _ANDROID_GRAPHICS_TYPEFACE_IMPL_H_ 65