1 | /* |
2 | * Copyright 2020 Google LLC |
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 SkCustomTypeface_DEFINED |
9 | #define SkCustomTypeface_DEFINED |
10 | |
11 | #include "include/core/SkFontMetrics.h" |
12 | #include "include/core/SkImage.h" |
13 | #include "include/core/SkPaint.h" |
14 | #include "include/core/SkPath.h" |
15 | #include "include/core/SkPicture.h" |
16 | #include "include/core/SkTypeface.h" |
17 | |
18 | #include <vector> |
19 | |
20 | class SkStream; |
21 | |
22 | class SkCustomTypefaceBuilder { |
23 | public: |
24 | SkCustomTypefaceBuilder(); |
25 | |
26 | void setGlyph(SkGlyphID, float advance, const SkPath&); |
27 | void setGlyph(SkGlyphID, float advance, const SkPath&, const SkPaint&); |
28 | void setGlyph(SkGlyphID, float advance, sk_sp<SkImage>, float scale); |
29 | void setGlyph(SkGlyphID, float advance, sk_sp<SkPicture>); |
30 | |
31 | void setMetrics(const SkFontMetrics& fm, float scale = 1); |
32 | |
33 | sk_sp<SkTypeface> detach(); |
34 | |
35 | private: |
36 | std::vector<SkPath> fPaths; |
37 | std::vector<float> fAdvances; |
38 | SkFontMetrics fMetrics; |
39 | |
40 | static sk_sp<SkTypeface> Deserialize(SkStream*); |
41 | |
42 | friend class SkTypeface; |
43 | }; |
44 | |
45 | #endif |
46 | |