| Flutter Impeller |

typeface_stb.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_TYPOGRAPHER_BACKENDS_STB_TYPEFACE_STB_H_
6 #define FLUTTER_IMPELLER_TYPOGRAPHER_BACKENDS_STB_TYPEFACE_STB_H_
7
8 #include "flutter/fml/mapping.h"
9 #include "flutter/third_party/stb/stb_truetype.h"
10 #include "impeller/base/backend_cast.h"
11 #include "impeller/typographer/typeface.h"
12
13 namespace impeller {
14
15 class TypefaceSTB final : public Typeface,
16 public BackendCast<TypefaceSTB, Typeface> {
17 public:
18 // "Typical" conversion from font Points to Pixels.
19 // This assumes a constant pixels per em.
20 static constexpr float kPointsToPixels = 96.0 / 72.0;
21
22 explicit TypefaceSTB(std::unique_ptr<fml::Mapping> typeface_mapping);
23
24 ~TypefaceSTB() override;
25
26 // |Typeface|
27 bool IsValid() const override;
28
29 // |Comparable<Typeface>|
30 std::size_t GetHash() const override;
31
32 // |Comparable<Typeface>|
33 bool IsEqual(const Typeface& other) const override;
34
35 const uint8_t* GetTypefaceFile() const;
36 const stbtt_fontinfo* GetFontInfo() const;
37
38 private:
39 std::unique_ptr<fml::Mapping> typeface_mapping_;
40 std::unique_ptr<stbtt_fontinfo> font_info_;
41 bool is_valid_ = false;
42
43 TypefaceSTB(const TypefaceSTB&) = delete;
44
45 TypefaceSTB& operator=(const TypefaceSTB&) = delete;
46 };
47
48 } // namespace impeller
49
50 #endif // FLUTTER_IMPELLER_TYPOGRAPHER_BACKENDS_STB_TYPEFACE_STB_H_
impeller::TypefaceSTB::GetFontInfo
const stbtt_fontinfo * GetFontInfo() const
Definition: typeface_stb.cc:49
impeller::TypefaceSTB::GetHash
std::size_t GetHash() const override
Definition: typeface_stb.cc:33
impeller::TypefaceSTB::IsValid
bool IsValid() const override
Definition: typeface_stb.cc:29
impeller::TypefaceSTB
Definition: typeface_stb.h:15
backend_cast.h
impeller::TypefaceSTB::TypefaceSTB
TypefaceSTB(std::unique_ptr< fml::Mapping > typeface_mapping)
Definition: typeface_stb.cc:14
impeller::Typeface
A typeface, usually obtained from a font-file, on disk describes the intrinsic properties of the font...
Definition: typeface.h:18
typeface.h
impeller::TypefaceSTB::IsEqual
bool IsEqual(const Typeface &other) const override
Definition: typeface_stb.cc:40
impeller::BackendCast
Definition: backend_cast.h:11
impeller::TypefaceSTB::~TypefaceSTB
~TypefaceSTB() override
impeller::TypefaceSTB::kPointsToPixels
static constexpr float kPointsToPixels
Definition: typeface_stb.h:20
impeller::TypefaceSTB::GetTypefaceFile
const uint8_t * GetTypefaceFile() const
Definition: typeface_stb.cc:45
impeller
Definition: allocation.cc:12