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"
14 
15 namespace impeller::interop {
16 
17 class TypographyContext final
18  : public Object<TypographyContext,
19  IMPELLER_INTERNAL_HANDLE_NAME(ImpellerTypographyContext)> {
20  public:
22 
23  ~TypographyContext() override;
24 
26 
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_
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...
TypographyContext(const TypographyContext &)=delete
TypographyContext & operator=(const TypographyContext &)=delete
const std::shared_ptr< txt::FontCollection > & GetFontCollection() const