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 "include/core/SkRect.h" 12 #include "include/core/SkString.h" 13 #include "include/private/SkBitmaskEnum.h" 14 15 /** \class SkAdvancedTypefaceMetrics 16 17 The SkAdvancedTypefaceMetrics class is used by the PDF backend to correctly 18 embed typefaces. This class is created and filled in with information by 19 SkTypeface::getAdvancedMetrics. 20 */ 21 struct SkAdvancedTypefaceMetrics { 22 // The PostScript name of the font. See `FontName` and `BaseFont` in PDF standard. 23 SkString fPostScriptName; 24 SkString fFontName; 25 26 // These enum values match the values used in the PDF file format. 27 enum StyleFlags : uint32_t { 28 kFixedPitch_Style = 0x00000001, 29 kSerif_Style = 0x00000002, 30 kScript_Style = 0x00000008, 31 kItalic_Style = 0x00000040, 32 kAllCaps_Style = 0x00010000, 33 kSmallCaps_Style = 0x00020000, 34 kForceBold_Style = 0x00040000 35 }; 36 StyleFlags fStyle = (StyleFlags)0; // Font style characteristics. 37 38 enum FontType : uint8_t { 39 kType1_Font, 40 kType1CID_Font, 41 kCFF_Font, 42 kTrueType_Font, 43 kOther_Font, 44 }; 45 // The type of the underlying font program. This field determines which 46 // of the following fields are valid. If it is kOther_Font the per glyph 47 // information will never be populated. 48 FontType fType = kOther_Font; 49 50 enum FontFlags : uint8_t { 51 kVariable_FontFlag = 1 << 0, //!<May be true for Type1, CFF, or TrueType fonts. 52 kNotEmbeddable_FontFlag = 1 << 1, //!<May not be embedded. 53 kNotSubsettable_FontFlag = 1 << 2, //!<May not be subset. 54 kAltDataFormat_FontFlag = 1 << 3, //!<Data compressed. Table access may still work. 55 }; 56 FontFlags fFlags = (FontFlags)0; // Global font flags. 57 58 int16_t fItalicAngle = 0; // Counterclockwise degrees from vertical of the 59 // dominant vertical stroke for an Italic face. 60 // The following fields are all in font units. 61 int16_t fAscent = 0; // Max height above baseline, not including accents. 62 int16_t fDescent = 0; // Max depth below baseline (negative). 63 int16_t fStemV = 0; // Thickness of dominant vertical stem. 64 int16_t fCapHeight = 0; // Height (from baseline) of top of flat capitals. 65 66 SkIRect fBBox = {0, 0, 0, 0}; // The bounding box of all glyphs (in font units). 67 }; 68 69 namespace sknonstd { 70 template <> struct is_bitmask_enum<SkAdvancedTypefaceMetrics::FontFlags> : std::true_type {}; 71 template <> struct is_bitmask_enum<SkAdvancedTypefaceMetrics::StyleFlags> : std::true_type {}; 72 } // namespace sknonstd 73 74 #endif 75