| Flutter Impeller |

typography_context.h
Go to the documentation of this file.
1 // Copyright 2013 The Flutter Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
4
5 #ifndef FLUTTER_IMPELLER_TOOLKIT_INTEROP_TYPOGRAPHY_CONTEXT_H_
6 #define FLUTTER_IMPELLER_TOOLKIT_INTEROP_TYPOGRAPHY_CONTEXT_H_
7
8 #include <memory>
9
10 #include "flutter/fml/mapping.h"
11 #include "flutter/third_party/skia/modules/skparagraph/include/TypefaceFontProvider.h"
12 #include "flutter/txt/src/txt/font_collection.h"
13 #include "impeller/toolkit/interop/impeller.h"
14 #include "impeller/toolkit/interop/object.h"
15
16 namespace impeller::interop {
17
18 class TypographyContext final
19 : public Object<TypographyContext,
20 IMPELLER_INTERNAL_HANDLE_NAME(ImpellerTypographyContext)> {
21 public:
22 TypographyContext();
23
24 ~TypographyContext() override;
25
26 TypographyContext(const TypographyContext&) = delete;
27
28 TypographyContext& operator=(const TypographyContext&) = delete;
29
30 bool IsValid() const;
31
32 const std::shared_ptr<txt::FontCollection>& GetFontCollection() const;
33
34 //----------------------------------------------------------------------------
35 /// @brief Registers custom font data. If an alias for the family name is
36 /// provided, subsequent lookups will need to use that same alias.
37 /// If not, the family name will be read from the font data.
38 ///
39 /// @param[in] font_data The font data
40 /// @param[in] family_name_alias The family name alias
41 ///
42 /// @return If the font data could be successfully registered.
43 ///
44 bool RegisterFont(std::unique_ptr<fml::Mapping> font_data,
45 const char* family_name_alias);
46
47 private:
48 std::shared_ptr<txt::FontCollection> collection_;
49 sk_sp<skia::textlayout::TypefaceFontProvider> asset_font_manager_;
50 };
51
52 } // namespace impeller::interop
53
54 #endif // FLUTTER_IMPELLER_TOOLKIT_INTEROP_TYPOGRAPHY_CONTEXT_H_
impeller::interop::Object
Definition: object.h:56
impeller::interop::TypographyContext
Definition: typography_context.h:20
impeller::interop::TypographyContext::RegisterFont
bool RegisterFont(std::unique_ptr< fml::Mapping > font_data, const char *family_name_alias)
Registers custom font data. If an alias for the family name is provided, subsequent lookups will need...
Definition: typography_context.cc:68
impeller::interop::TypographyContext::IsValid
bool IsValid() const
Definition: typography_context.cc:34
impeller::interop::TypographyContext::TypographyContext
TypographyContext()
Definition: typography_context.cc:16
impeller::interop::TypographyContext::TypographyContext
TypographyContext(const TypographyContext &)=delete
impeller::interop::TypographyContext::operator=
TypographyContext & operator=(const TypographyContext &)=delete
impeller::interop::TypographyContext::GetFontCollection
const std::shared_ptr< txt::FontCollection > & GetFontCollection() const
Definition: typography_context.cc:39
impeller::interop::TypographyContext::~TypographyContext
~TypographyContext() override
impeller.h
impeller::interop
Definition: context_gles.cc:12
object.h