Flutter Engine
The Flutter Engine
SkFontArguments.h
Go to the documentation of this file.
1/*
2 * Copyright 2017 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 SkFontArguments_DEFINED
9#define SkFontArguments_DEFINED
10
14
15/** Represents a set of actual arguments for a font. */
18 struct Coordinate {
20 float value;
21 };
24 };
25
26 /** Specify a palette to use and overrides for palette entries.
27 *
28 * `overrides` is a list of pairs of palette entry index and color.
29 * The overriden palette entries will use the associated color.
30 * Override pairs with palette entry indices out of range will not be applied.
31 * Later override entries override earlier ones.
32 */
33 struct Palette {
34 struct Override {
35 uint16_t index;
37 };
38 int index;
41 };
42
44 : fCollectionIndex(0)
45 , fVariationDesignPosition{nullptr, 0}
46 , fPalette{0, nullptr, 0} {}
47
48 /** Specify the index of the desired font.
49 *
50 * Font formats like ttc, dfont, cff, cid, pfr, t42, t1, and fon may actually be indexed
51 * collections of fonts.
52 */
53 SkFontArguments& setCollectionIndex(int collectionIndex) {
54 fCollectionIndex = collectionIndex;
55 return *this;
56 }
57
58 /** Specify a position in the variation design space.
59 *
60 * Any axis not specified will use the default value.
61 * Any specified axis not actually present in the font will be ignored.
62 *
63 * @param position not copied. The value must remain valid for life of SkFontArguments.
64 */
66 fVariationDesignPosition.coordinates = position.coordinates;
67 fVariationDesignPosition.coordinateCount = position.coordinateCount;
68 return *this;
69 }
70
71 int getCollectionIndex() const {
72 return fCollectionIndex;
73 }
74
76 return fVariationDesignPosition;
77 }
78
80 fPalette.index = palette.index;
81 fPalette.overrides = palette.overrides;
82 fPalette.overrideCount = palette.overrideCount;
83 return *this;
84 }
85
86 Palette getPalette() const { return fPalette; }
87
88private:
89 int fCollectionIndex;
90 VariationPosition fVariationDesignPosition;
91 Palette fPalette;
92};
93
94#endif
uint32_t SkColor
Definition: SkColor.h:37
uint32_t SkFourByteTag
Definition: SkTypes.h:166
const Override * overrides
SkFontArguments & setCollectionIndex(int collectionIndex)
SkFontArguments & setVariationDesignPosition(VariationPosition position)
SkFontArguments & setPalette(Palette palette)
VariationPosition getVariationDesignPosition() const
Palette getPalette() const
int getCollectionIndex() const