Line data Source code
1 : /*
2 : * Copyright 2013 Google Inc.
3 : *
4 : * Use of this source code is governed by a BSD-style license that can be
5 : * found in the LICENSE file.
6 : */
7 :
8 : #ifndef SkFontStyle_DEFINED
9 : #define SkFontStyle_DEFINED
10 :
11 : #include "SkTypes.h"
12 :
13 : class SK_API SkFontStyle {
14 : public:
15 : enum Weight {
16 : kInvisible_Weight = 0,
17 : kThin_Weight = 100,
18 : kExtraLight_Weight = 200,
19 : kLight_Weight = 300,
20 : kNormal_Weight = 400,
21 : kMedium_Weight = 500,
22 : kSemiBold_Weight = 600,
23 : kBold_Weight = 700,
24 : kExtraBold_Weight = 800,
25 : kBlack_Weight = 900,
26 : kExtraBlack_Weight = 1000,
27 : };
28 :
29 : enum Width {
30 : kUltraCondensed_Width = 1,
31 : kExtraCondensed_Width = 2,
32 : kCondensed_Width = 3,
33 : kSemiCondensed_Width = 4,
34 : kNormal_Width = 5,
35 : kSemiExpanded_Width = 6,
36 : kExpanded_Width = 7,
37 : kExtraExpanded_Width = 8,
38 : kUltraExpanded_Width = 9,
39 : };
40 :
41 : enum Slant {
42 : kUpright_Slant,
43 : kItalic_Slant,
44 : kOblique_Slant,
45 : };
46 :
47 : SkFontStyle();
48 : SkFontStyle(int weight, int width, Slant);
49 :
50 : static SkFontStyle FromOldStyle(unsigned oldStyle);
51 :
52 : bool operator==(const SkFontStyle& rhs) const {
53 : return fUnion.fU32 == rhs.fUnion.fU32;
54 : }
55 :
56 0 : int weight() const { return fUnion.fR.fWeight; }
57 0 : int width() const { return fUnion.fR.fWidth; }
58 0 : Slant slant() const { return (Slant)fUnion.fR.fSlant; }
59 :
60 : private:
61 : union {
62 : struct {
63 : uint16_t fWeight; // 100 .. 900
64 : uint8_t fWidth; // 1 .. 9
65 : uint8_t fSlant; // 0 .. 2
66 : } fR;
67 : uint32_t fU32;
68 : } fUnion;
69 : };
70 :
71 : #endif
|