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