xref: /aosp_15_r20/external/skia/include/core/SkFontParameters.h (revision c8dee2aa9b3f27cf6c858bd81872bdeb2c07ed17)
1 /*
2  * Copyright 2018 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 SkFontParameters_DEFINED
9 #define SkFontParameters_DEFINED
10 
11 #include "include/core/SkFourByteTag.h"
12 
13 #include <cstdint>
14 
15 struct SkFontParameters {
16     struct Variation {
17         // Parameters in a variation font axis.
18         struct Axis {
AxisSkFontParameters::Variation::Axis19             constexpr Axis() : tag(0), min(0), def(0), max(0), flags(0) {}
AxisSkFontParameters::Variation::Axis20             constexpr Axis(SkFourByteTag tag, float min, float def, float max, bool hidden) :
21                 tag(tag), min(min), def(def), max(max), flags(hidden ? HIDDEN : 0) {}
22 
23             // Four character identifier of the font axis (weight, width, slant, italic...).
24             SkFourByteTag tag;
25             // Minimum value supported by this axis.
26             float min;
27             // Default value set by this axis.
28             float def;
29             // Maximum value supported by this axis. The maximum can equal the minimum.
30             float max;
31             // Return whether this axis is recommended to be remain hidden in user interfaces.
isHiddenSkFontParameters::Variation::Axis32             bool isHidden() const { return flags & HIDDEN; }
33             // Set this axis to be remain hidden in user interfaces.
setHiddenSkFontParameters::Variation::Axis34             void setHidden(bool hidden) { flags = hidden ? (flags | HIDDEN) : (flags & ~HIDDEN); }
35         private:
36             static constexpr uint16_t HIDDEN = 0x0001;
37             // Attributes for a font axis.
38             uint16_t flags;
39         };
40     };
41 };
42 
43 #endif
44