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