blob: 0ccf56202552936c5f48593739af813f980bd2d4 [file] [log] [blame]
vandebo@chromium.orgc48b2b32011-02-02 02:11:22 +00001/*
epoger@google.comec3ed6a2011-07-28 14:26:00 +00002 * Copyright 2011 Google Inc.
vandebo@chromium.orgc48b2b32011-02-02 02:11:22 +00003 *
epoger@google.comec3ed6a2011-07-28 14:26:00 +00004 * Use of this source code is governed by a BSD-style license that can be
5 * found in the LICENSE file.
vandebo@chromium.orgc48b2b32011-02-02 02:11:22 +00006 */
7
8#ifndef SkAdvancedTypefaceMetrics_DEFINED
9#define SkAdvancedTypefaceMetrics_DEFINED
10
Mike Kleinc0bd9f92019-04-23 12:05:21 -050011#include "include/core/SkRect.h"
12#include "include/core/SkString.h"
13#include "include/private/SkBitmaskEnum.h"
mtklein5f939ab2016-03-16 10:28:35 -070014
vandebo@chromium.orgc48b2b32011-02-02 02:11:22 +000015/** \class SkAdvancedTypefaceMetrics
16
17 The SkAdvancedTypefaceMetrics class is used by the PDF backend to correctly
bungeman7be2eb82015-02-23 08:25:00 -080018 embed typefaces. This class is created and filled in with information by
Hal Canary209e4b12017-05-04 14:23:55 -040019 SkTypeface::getAdvancedMetrics.
vandebo@chromium.orgc48b2b32011-02-02 02:11:22 +000020*/
Hal Canary209e4b12017-05-04 14:23:55 -040021struct SkAdvancedTypefaceMetrics {
Hal Canarye1fec192018-03-29 10:59:02 -070022 // The PostScript name of the font. See `FontName` and `BaseFont` in PDF standard.
23 SkString fPostScriptName;
vandebo@chromium.orgc48b2b32011-02-02 02:11:22 +000024 SkString fFontName;
25
Hal Canary9e146962017-05-08 14:16:06 -040026 // 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
halcanary32875882016-08-16 09:36:23 -070038 enum FontType : uint8_t {
vandebo@chromium.orgc48b2b32011-02-02 02:11:22 +000039 kType1_Font,
40 kType1CID_Font,
41 kCFF_Font,
42 kTrueType_Font,
43 kOther_Font,
vandebo@chromium.orgc48b2b32011-02-02 02:11:22 +000044 };
45 // The type of the underlying font program. This field determines which
vandebo0f9bad02014-06-19 11:05:39 -070046 // of the following fields are valid. If it is kOther_Font the per glyph
47 // information will never be populated.
Hal Canary209e4b12017-05-04 14:23:55 -040048 FontType fType = kOther_Font;
vandebo@chromium.orgc48b2b32011-02-02 02:11:22 +000049
halcanary32875882016-08-16 09:36:23 -070050 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.
vandebo0f9bad02014-06-19 11:05:39 -070054 };
Hal Canary209e4b12017-05-04 14:23:55 -040055 FontFlags fFlags = (FontFlags)0; // Global font flags.
vandebo0f9bad02014-06-19 11:05:39 -070056
Hal Canary209e4b12017-05-04 14:23:55 -040057 int16_t fItalicAngle = 0; // Counterclockwise degrees from vertical of the
58 // dominant vertical stroke for an Italic face.
vandebo@chromium.orgc48b2b32011-02-02 02:11:22 +000059 // The following fields are all in font units.
Hal Canary209e4b12017-05-04 14:23:55 -040060 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.
vandebo@chromium.orgc48b2b32011-02-02 02:11:22 +000064
Hal Canary209e4b12017-05-04 14:23:55 -040065 SkIRect fBBox = {0, 0, 0, 0}; // The bounding box of all glyphs (in font units).
vandebo@chromium.orgc48b2b32011-02-02 02:11:22 +000066};
67
Mike Kleindc976a92020-04-30 06:45:25 -050068namespace sknonstd {
halcanary32875882016-08-16 09:36:23 -070069template <> struct is_bitmask_enum<SkAdvancedTypefaceMetrics::FontFlags> : std::true_type {};
70template <> struct is_bitmask_enum<SkAdvancedTypefaceMetrics::StyleFlags> : std::true_type {};
71}
vandebo@chromium.org6f72d1e2011-02-14 23:19:59 +000072
vandebo@chromium.orgc48b2b32011-02-02 02:11:22 +000073#endif