Flutter Engine
The Flutter Engine
Loading...
Searching...
No Matches
Font.h
Go to the documentation of this file.
1/*
2 * Copyright 2022 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 SkottieFont_DEFINED
9#define SkottieFont_DEFINED
10
16#include "src/core/SkTHash.h"
17
18#include <memory>
19#include <utility>
20#include <vector>
21
22class SkPath;
23class SkTypeface;
24struct SkSize;
25
26namespace skjson { class ObjectValue; }
27
28namespace skottie::internal {
29
30class AnimationBuilder;
31
32// Font backed by Lottie character data (glyph paths and glyph compositions).
34public:
36
38
39 class Builder final : SkNoncopyable {
40 public:
42 std::unique_ptr<CustomFont> detach();
43
44 private:
45 static bool ParseGlyphPath(const AnimationBuilder*, const skjson::ObjectValue&, SkPath*);
46 static sk_sp<sksg::RenderNode> ParseGlyphComp(const AnimationBuilder*,
48 SkSize*);
49
50 GlyphCompMap fGlyphComps;
51 SkCustomTypefaceBuilder fCustomBuilder;
52 };
53
54 // Helper for resolving (SkTypeface, SkGlyphID) tuples to a composition root.
55 // Used post-shaping, to substitute composition glyphs in the rendering tree.
56 class GlyphCompMapper final : public SkRefCnt {
57 public:
58 explicit GlyphCompMapper(std::vector<std::unique_ptr<CustomFont>>&& fonts)
59 : fFonts(std::move(fonts)) {}
60
61 ~GlyphCompMapper() override = default;
62
64
65 private:
66 const std::vector<std::unique_ptr<CustomFont>> fFonts;
67 };
68
69 const sk_sp<SkTypeface>& typeface() const { return fTypeface; }
70
71 int glyphCompCount() const { return fGlyphComps.count(); }
72
73private:
75
76 const GlyphCompMap fGlyphComps;
77 const sk_sp<SkTypeface> fTypeface;
78};
79
80} // namespace skottie::internal
81
82#endif // SkottieFont_DEFINED
uint16_t SkGlyphID
Definition SkTypes.h:179
int count() const
Definition SkTHash.h:460
bool parseGlyph(const AnimationBuilder *, const skjson::ObjectValue &)
Definition Font.cpp:26
std::unique_ptr< CustomFont > detach()
Definition Font.cpp:200
GlyphCompMapper(std::vector< std::unique_ptr< CustomFont > > &&fonts)
Definition Font.h:58
sk_sp< sksg::RenderNode > getGlyphComp(const SkTypeface *, SkGlyphID) const
Definition Font.cpp:212
int glyphCompCount() const
Definition Font.h:71
skia_private::THashMap< SkGlyphID, sk_sp< sksg::RenderNode > > GlyphCompMap
Definition Font.h:37
const sk_sp< SkTypeface > & typeface() const
Definition Font.h:69
Definition ref_ptr.h:256