OLD | NEW |
1 /* | 1 /* |
2 * Copyright 2011 Google Inc. | 2 * Copyright 2011 Google Inc. |
3 * | 3 * |
4 * Use of this source code is governed by a BSD-style license that can be | 4 * Use of this source code is governed by a BSD-style license that can be |
5 * found in the LICENSE file. | 5 * found in the LICENSE file. |
6 */ | 6 */ |
7 | 7 |
8 | |
9 #ifndef SkAdvancedTypefaceMetrics_DEFINED | 8 #ifndef SkAdvancedTypefaceMetrics_DEFINED |
10 #define SkAdvancedTypefaceMetrics_DEFINED | 9 #define SkAdvancedTypefaceMetrics_DEFINED |
11 | 10 |
| 11 #include "SkBitmaskEnum.h" |
12 #include "SkRect.h" | 12 #include "SkRect.h" |
13 #include "SkRefCnt.h" | 13 #include "SkRefCnt.h" |
14 #include "SkString.h" | 14 #include "SkString.h" |
15 #include "SkTDArray.h" | 15 #include "SkTDArray.h" |
16 #include "SkTemplates.h" | |
17 #include "SkSinglyLinkedList.h" | |
18 | 16 |
19 /** \class SkAdvancedTypefaceMetrics | 17 /** \class SkAdvancedTypefaceMetrics |
20 | 18 |
21 The SkAdvancedTypefaceMetrics class is used by the PDF backend to correctly | 19 The SkAdvancedTypefaceMetrics class is used by the PDF backend to correctly |
22 embed typefaces. This class is created and filled in with information by | 20 embed typefaces. This class is created and filled in with information by |
23 SkTypeface::getAdvancedTypefaceMetrics. | 21 SkTypeface::getAdvancedTypefaceMetrics. |
24 */ | 22 */ |
25 | |
26 class SkAdvancedTypefaceMetrics : public SkRefCnt { | 23 class SkAdvancedTypefaceMetrics : public SkRefCnt { |
27 public: | 24 public: |
28 | 25 |
29 SkAdvancedTypefaceMetrics() | 26 SkAdvancedTypefaceMetrics() |
30 : fType(SkAdvancedTypefaceMetrics::kOther_Font) | 27 : fType(SkAdvancedTypefaceMetrics::kOther_Font) |
31 , fFlags(SkAdvancedTypefaceMetrics::kEmpty_FontFlag) | 28 , fFlags((FontFlags)0) |
32 , fLastGlyphID(0) | 29 , fLastGlyphID(0) |
33 , fEmSize(0) | 30 , fEmSize(0) |
34 , fStyle(0) | 31 , fStyle((StyleFlags)0) |
35 , fItalicAngle(0) | 32 , fItalicAngle(0) |
36 , fAscent(0) | 33 , fAscent(0) |
37 , fDescent(0) | 34 , fDescent(0) |
38 , fStemV(0) | 35 , fStemV(0) |
39 , fCapHeight(0) | 36 , fCapHeight(0) |
40 , fBBox(SkIRect::MakeEmpty()) {} | 37 , fBBox(SkIRect::MakeEmpty()) {} |
41 | 38 |
42 ~SkAdvancedTypefaceMetrics() {} | 39 ~SkAdvancedTypefaceMetrics() {} |
43 | 40 |
44 SkString fFontName; | 41 SkString fFontName; |
45 | 42 |
46 enum FontType { | 43 enum FontType : uint8_t { |
47 kType1_Font, | 44 kType1_Font, |
48 kType1CID_Font, | 45 kType1CID_Font, |
49 kCFF_Font, | 46 kCFF_Font, |
50 kTrueType_Font, | 47 kTrueType_Font, |
51 kOther_Font, | 48 kOther_Font, |
52 }; | 49 }; |
53 // The type of the underlying font program. This field determines which | 50 // The type of the underlying font program. This field determines which |
54 // of the following fields are valid. If it is kOther_Font the per glyph | 51 // of the following fields are valid. If it is kOther_Font the per glyph |
55 // information will never be populated. | 52 // information will never be populated. |
56 FontType fType; | 53 FontType fType; |
57 | 54 |
58 enum FontFlags { | 55 enum FontFlags : uint8_t { |
59 kEmpty_FontFlag = 0x0, //!<No flags set | 56 kMultiMaster_FontFlag = 0x01, //!<May be true for Type1, CFF, or Tru
eType fonts. |
60 kMultiMaster_FontFlag = 0x1, //!<May be true for Type1, CFF, or True
Type fonts. | 57 kNotEmbeddable_FontFlag = 0x02, //!<May not be embedded. |
61 kNotEmbeddable_FontFlag = 0x2, //!<May not be embedded. | 58 kNotSubsettable_FontFlag = 0x04, //!<May not be subset. |
62 kNotSubsettable_FontFlag = 0x4, //!<May not be subset. | |
63 }; | 59 }; |
64 // Global font flags. | 60 FontFlags fFlags; // Global font flags. |
65 FontFlags fFlags; | |
66 | 61 |
67 uint16_t fLastGlyphID; // The last valid glyph ID in the font. | 62 uint16_t fLastGlyphID; // The last valid glyph ID in the font. |
68 uint16_t fEmSize; // The size of the em box (defines font units). | 63 uint16_t fEmSize; // The size of the em box (defines font units). |
69 | 64 |
70 // These enum values match the values used in the PDF file format. | 65 // These enum values match the values used in the PDF file format. |
71 enum StyleFlags { | 66 enum StyleFlags : uint32_t { |
72 kFixedPitch_Style = 0x00001, | 67 kFixedPitch_Style = 0x00000001, |
73 kSerif_Style = 0x00002, | 68 kSerif_Style = 0x00000002, |
74 kScript_Style = 0x00008, | 69 kScript_Style = 0x00000008, |
75 kItalic_Style = 0x00040, | 70 kItalic_Style = 0x00000040, |
76 kAllCaps_Style = 0x10000, | 71 kAllCaps_Style = 0x00010000, |
77 kSmallCaps_Style = 0x20000, | 72 kSmallCaps_Style = 0x00020000, |
78 kForceBold_Style = 0x40000 | 73 kForceBold_Style = 0x00040000 |
79 }; | 74 }; |
80 uint16_t fStyle; // Font style characteristics. | 75 StyleFlags fStyle; // Font style characteristics. |
| 76 |
81 int16_t fItalicAngle; // Counterclockwise degrees from vertical of the | 77 int16_t fItalicAngle; // Counterclockwise degrees from vertical of the |
82 // dominant vertical stroke for an Italic face. | 78 // dominant vertical stroke for an Italic face. |
83 // The following fields are all in font units. | 79 // The following fields are all in font units. |
84 int16_t fAscent; // Max height above baseline, not including accents. | 80 int16_t fAscent; // Max height above baseline, not including accents. |
85 int16_t fDescent; // Max depth below baseline (negative). | 81 int16_t fDescent; // Max depth below baseline (negative). |
86 int16_t fStemV; // Thickness of dominant vertical stem. | 82 int16_t fStemV; // Thickness of dominant vertical stem. |
87 int16_t fCapHeight; // Height (from baseline) of top of flat capitals. | 83 int16_t fCapHeight; // Height (from baseline) of top of flat capitals. |
88 | 84 |
89 SkIRect fBBox; // The bounding box of all glyphs (in font units). | 85 SkIRect fBBox; // The bounding box of all glyphs (in font units). |
90 | 86 |
91 // The names of each glyph, only populated for postscript fonts. | 87 // The names of each glyph, only populated for postscript fonts. |
92 SkTArray<SkString> fGlyphNames; | 88 SkTArray<SkString> fGlyphNames; |
93 | 89 |
94 // The mapping from glyph to Unicode, only populated if | 90 // The mapping from glyph to Unicode, only populated if |
95 // kToUnicode_PerGlyphInfo is passed to GetAdvancedTypefaceMetrics. | 91 // kToUnicode_PerGlyphInfo is passed to GetAdvancedTypefaceMetrics. |
96 SkTDArray<SkUnichar> fGlyphToUnicode; | 92 SkTDArray<SkUnichar> fGlyphToUnicode; |
97 | 93 |
98 private: | 94 private: |
99 typedef SkRefCnt INHERITED; | 95 typedef SkRefCnt INHERITED; |
100 }; | 96 }; |
101 | 97 |
| 98 namespace skstd { |
| 99 template <> struct is_bitmask_enum<SkAdvancedTypefaceMetrics::FontFlags> : std::
true_type {}; |
| 100 template <> struct is_bitmask_enum<SkAdvancedTypefaceMetrics::StyleFlags> : std:
:true_type {}; |
| 101 } |
102 | 102 |
103 #endif | 103 #endif |
OLD | NEW |