| 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/third_party/skia/modules/skparagraph/include/TypefaceFontProvider.h"
11 #include "flutter/txt/src/txt/font_collection.h"
12 #include "impeller/toolkit/interop/impeller.h"
13 #include "impeller/toolkit/interop/object.h"
14
15 namespace impeller::interop {
16
17 class TypographyContext final
18 : public Object<TypographyContext,
19 IMPELLER_INTERNAL_HANDLE_NAME(ImpellerTypographyContext)> {
20 public:
21 TypographyContext();
22
23 ~TypographyContext() override;
24
25 TypographyContext(const TypographyContext&) = delete;
26
27 TypographyContext& operator=(const TypographyContext&) = delete;
28
29 bool IsValid() const;
30
31 const std::shared_ptr<txt::FontCollection>& GetFontCollection() const;
32
33 //----------------------------------------------------------------------------
34 /// @brief Registers custom font data. If an alias for the family name is
35 /// provided, subsequent lookups will need to use that same alias.
36 /// If not, the family name will be read from the font data.
37 ///
38 /// @param[in] font_data The font data
39 /// @param[in] family_name_alias The family name alias
40 ///
41 /// @return If the font data could be successfully registered.
42 ///
43 bool RegisterFont(std::unique_ptr<fml::Mapping> font_data,
44 const char* family_name_alias);
45
46 private:
47 std::shared_ptr<txt::FontCollection> collection_;
48 sk_sp<skia::textlayout::TypefaceFontProvider> asset_font_manager_;
49 };
50
51 } // namespace impeller::interop
52
53 #endif // FLUTTER_IMPELLER_TOOLKIT_INTEROP_TYPOGRAPHY_CONTEXT_H_
impeller::interop::Object
Definition: object.h:56
impeller::interop::TypographyContext
Definition: typography_context.h:19
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