1
2/*
3 * Copyright 2006 The Android Open Source Project
4 *
5 * Use of this source code is governed by a BSD-style license that can be
6 * found in the LICENSE file.
7 */
8
9
10#ifndef SkFontHost_DEFINED
11#define SkFontHost_DEFINED
12
13#include "SkTypeface.h"
14
15class SkDescriptor;
16class SkScalerContext;
17struct SkScalerContextRec;
18class SkStream;
19class SkWStream;
20
21/** \class SkFontHost
22
23    This class is ported to each environment. It is responsible for bridging
24    the gap between the (sort of) abstract class SkTypeface and the
25    platform-specific implementation that provides access to font files.
26
27    One basic task is for each create (subclass of) SkTypeface, the FontHost is
28    responsible for assigning a uniqueID. The ID should be unique for the
29    underlying font file/data, not unique per typeface instance. Thus it is
30    possible/common to request a typeface for the same font more than once
31    (e.g. asking for the same font by name several times). The FontHost may
32    return seperate typeface instances in that case, or it may choose to use a
33    cache and return the same instance (but calling typeface->ref(), since the
34    caller is always responsible for calling unref() on each instance that is
35    returned). Either way, the fontID for those instance(s) will be the same.
36    In addition, the fontID should never be set to 0. That value is used as a
37    sentinel to indicate no-font-id.
38
39    The major aspects are:
40    1) Given either a name/style, return a subclass of SkTypeface that
41        references the closest matching font available on the host system.
42    2) Given the data for a font (either in a stream or a file name), return
43        a typeface that allows access to that data.
44    3) Each typeface instance carries a 32bit ID for its corresponding font.
45        SkFontHost turns that ID into a stream to access the font's data.
46    4) Given a font ID, return a subclass of SkScalerContext, which connects a
47        font scaler (e.g. freetype or other) to the font's data.
48    5) Utilites to manage the font cache (budgeting) and gamma correction
49*/
50class SK_API SkFontHost {
51public:
52    /** LCDs either have their color elements arranged horizontally or
53     vertically. When rendering subpixel glyphs we need to know which way
54     round they are.
55
56     Note, if you change this after startup, you'll need to flush the glyph
57     cache because it'll have the wrong type of masks cached.
58
59     @deprecated use SkPixelGeometry instead.
60     */
61    enum LCDOrientation {
62        kHorizontal_LCDOrientation = 0,    //!< this is the default
63        kVertical_LCDOrientation   = 1
64    };
65
66    /** @deprecated set on Device creation. */
67    static void SetSubpixelOrientation(LCDOrientation orientation);
68    /** @deprecated get from Device. */
69    static LCDOrientation GetSubpixelOrientation();
70
71    /** LCD color elements can vary in order. For subpixel text we need to know
72     the order which the LCDs uses so that the color fringes are in the
73     correct place.
74
75     Note, if you change this after startup, you'll need to flush the glyph
76     cache because it'll have the wrong type of masks cached.
77
78     kNONE_LCDOrder means that the subpixel elements are not spatially
79     separated in any usable fashion.
80
81     @deprecated use SkPixelGeometry instead.
82     */
83    enum LCDOrder {
84        kRGB_LCDOrder = 0,    //!< this is the default
85        kBGR_LCDOrder = 1,
86        kNONE_LCDOrder = 2
87    };
88
89    /** @deprecated set on Device creation. */
90    static void SetSubpixelOrder(LCDOrder order);
91    /** @deprecated get from Device. */
92    static LCDOrder GetSubpixelOrder();
93};
94
95#endif
96