1 // Copyright 2019 Google LLC.
2 #ifndef FontArguments_DEFINED
3 #define FontArguments_DEFINED
4 
5 #include <functional>
6 #include <vector>
7 #include "include/core/SkFontArguments.h"
8 #include "include/core/SkTypeface.h"
9 #include "drawing.h"
10 
11 namespace skia {
12 namespace textlayout {
13 
14 class FontArguments {
15 public:
16     FontArguments(const SkFontArguments&);
17     FontArguments(const FontArguments&) = default;
18     FontArguments(FontArguments&&) = default;
19 
20     FontArguments& operator=(const FontArguments&) = default;
21     FontArguments& operator=(FontArguments&&) = default;
22 
23 #ifndef USE_SKIA_TXT
24     sk_sp<SkTypeface> CloneTypeface(sk_sp<SkTypeface> typeface) const;
25 #else
26     std::shared_ptr<RSTypeface> CloneTypeface(std::shared_ptr<RSTypeface> typeface) const;
27 #endif
28 
29     friend bool operator==(const FontArguments& a, const FontArguments& b);
30     friend bool operator!=(const FontArguments& a, const FontArguments& b);
31     friend struct std::hash<FontArguments>;
32 
33 private:
34     FontArguments() = delete;
35 
36     int fCollectionIndex;
37     std::vector<SkFontArguments::VariationPosition::Coordinate> fCoordinates;
38     int fPaletteIndex;
39     std::vector<SkFontArguments::Palette::Override> fPaletteOverrides;
40 };
41 
42 }  // namespace textlayout
43 }  // namespace skia
44 
45 namespace std {
46     template<> struct hash<skia::textlayout::FontArguments> {
47         size_t operator()(const skia::textlayout::FontArguments& args) const;
48     };
49 }
50 
51 #endif  // FontArguments_DEFINED
52