SkAdvancedTypefaceMetrics.h 2.7 KB

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