| 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 #pragma once
6
7 #include "flutter/fml/macros.h"
8 #include "flutter/fml/mapping.h"
9 #include "impeller/base/backend_cast.h"
10 #include "impeller/typographer/typeface.h"
11 #include "third_party/stb/stb_truetype.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_;
42
43 FML_DISALLOW_COPY_AND_ASSIGN(TypefaceSTB);
44 };
45
46 } // namespace impeller
impeller::TypefaceSTB::GetFontInfo
const stbtt_fontinfo * GetFontInfo() const
Definition: typeface_stb.cc:50
impeller::TypefaceSTB::GetHash
std::size_t GetHash() const override
Definition: typeface_stb.cc:34
impeller::TypefaceSTB::IsValid
bool IsValid() const override
Definition: typeface_stb.cc:30
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:19
typeface.h
impeller::TypefaceSTB::IsEqual
bool IsEqual(const Typeface &other) const override
Definition: typeface_stb.cc:41
impeller::BackendCast
Definition: backend_cast.h:12
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:46
impeller
Definition: aiks_context.cc:10