Home | History | Annotate | Download | only in core
      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 "SkString.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         kMultiMaster_FontFlag    = 0x01,  //!<May be true for Type1, CFF, or TrueType fonts.
     52         kNotEmbeddable_FontFlag  = 0x02,  //!<May not be embedded.
     53         kNotSubsettable_FontFlag = 0x04,  //!<May not be subset.
     54     };
     55     FontFlags fFlags = (FontFlags)0;  // Global font flags.
     56 
     57     int16_t fItalicAngle = 0;  // Counterclockwise degrees from vertical of the
     58                                // dominant vertical stroke for an Italic face.
     59     // The following fields are all in font units.
     60     int16_t fAscent = 0;       // Max height above baseline, not including accents.
     61     int16_t fDescent = 0;      // Max depth below baseline (negative).
     62     int16_t fStemV = 0;        // Thickness of dominant vertical stem.
     63     int16_t fCapHeight = 0;    // Height (from baseline) of top of flat capitals.
     64 
     65     SkIRect fBBox = {0, 0, 0, 0};  // The bounding box of all glyphs (in font units).
     66 };
     67 
     68 namespace skstd {
     69 template <> struct is_bitmask_enum<SkAdvancedTypefaceMetrics::FontFlags> : std::true_type {};
     70 template <> struct is_bitmask_enum<SkAdvancedTypefaceMetrics::StyleFlags> : std::true_type {};
     71 }
     72 
     73 #endif
     74