Typeface.h revision c7064146f959caec058980ced144942c8044a169
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* createFromTypefaceWithVariation(Typeface* src,
46            const std::vector<minikin::FontVariation>& variations);
47
48    static Typeface* createWeightAlias(Typeface* src, int baseweight);
49
50    static Typeface* createFromFamilies(
51            std::vector<std::shared_ptr<minikin::FontFamily>>&& families);
52
53    static void setDefault(Typeface* face);
54
55    // Sets roboto font as the default typeface for testing purpose.
56    static void setRobotoTypefaceForTest();
57};
58
59}
60
61#endif  // _ANDROID_GRAPHICS_TYPEFACE_IMPL_H_
62