Skia
2D Graphics Library
SkFontParameters.h
Go to the documentation of this file.
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/SkScalar.h"
12 #include "include/core/SkTypes.h"
13 
15  struct Variation {
16  // Parameters in a variation font axis.
17  struct Axis {
18  constexpr Axis() : tag(0), min(0), def(0), max(0), flags(0) {}
19  constexpr Axis(SkFourByteTag tag, float min, float def, float max, bool hidden) :
20  tag(tag), min(min), def(def), max(max), flags(hidden ? HIDDEN : 0) {}
21 
22  // Four character identifier of the font axis (weight, width, slant, italic...).
24  // Minimum value supported by this axis.
25  float min;
26  // Default value set by this axis.
27  float def;
28  // Maximum value supported by this axis. The maximum can equal the minimum.
29  float max;
30  // Return whether this axis is recommended to be remain hidden in user interfaces.
31  bool isHidden() const { return flags & HIDDEN; }
32  // Set this axis to be remain hidden in user interfaces.
33  void setHidden(bool hidden) { flags = hidden ? (flags | HIDDEN) : (flags & ~HIDDEN); }
34  private:
35  static constexpr uint16_t HIDDEN = 0x0001;
36  // Attributes for a font axis.
37  uint16_t flags;
38  };
39  };
40 };
41 
42 #endif
uint32_t SkFourByteTag
Definition: SkTypes.h:158
Definition: SkFontParameters.h:17
constexpr Axis(SkFourByteTag tag, float min, float def, float max, bool hidden)
Definition: SkFontParameters.h:19
void setHidden(bool hidden)
Definition: SkFontParameters.h:33
bool isHidden() const
Definition: SkFontParameters.h:31
float max
Definition: SkFontParameters.h:29
float def
Definition: SkFontParameters.h:27
float min
Definition: SkFontParameters.h:25
constexpr Axis()
Definition: SkFontParameters.h:18
SkFourByteTag tag
Definition: SkFontParameters.h:23
Definition: SkFontParameters.h:15
Definition: SkFontParameters.h:14