| Flutter Impeller |

Public Member Functions | Static Public Attributes | List of all members
impeller::TypefaceSTB Class Referencefinal

`#include <typeface_stb.h>`

Inheritance diagram for impeller::TypefaceSTB:

## Public Member Functions
| TypefaceSTB (std::unique_ptr< fml::Mapping > typeface_mapping)
| ~TypefaceSTB () override
bool | IsValid () const override
std::size_t | GetHash () const override
bool | IsEqual (const Typeface &other) const override
const uint8_t * | GetTypefaceFile () const
const stbtt_fontinfo * | GetFontInfo () const
Public Member Functions inherited from impeller::Typeface
| Typeface ()
virtual | ~Typeface ()
Public Member Functions inherited from impeller::Comparable< Typeface >
virtual std::size_t | GetHash () const=0

## Static Public Attributes
static constexpr float | kPointsToPixels = 96.0 / 72.0

## Additional Inherited Members
Static Public Member Functions inherited from impeller::BackendCast< TypefaceSTB, Typeface >
static TypefaceSTB & | Cast (Typeface &base)
static const TypefaceSTB & | Cast (const Typeface &base)
static TypefaceSTB * | Cast (Typeface *base)
static const TypefaceSTB * | Cast (const Typeface *base)

## Detailed Description

Definition at line 15 of file typeface_stb.h.

## Constructor & Destructor Documentation

## ◆ TypefaceSTB()

impeller::TypefaceSTB::TypefaceSTB | ( | std::unique_ptr< fml::Mapping > | typeface_mapping | ) |
| explicit

Definition at line 14 of file typeface_stb.cc.

15 : typeface_mapping_(std::move(typeface_mapping)),
16 font_info_(std::make_unique<stbtt_fontinfo>()),
17 is_valid_(false) {
18 // We need an "offset" into the ttf file
19 auto offset = stbtt_GetFontOffsetForIndex(typeface_mapping_->GetMapping(), 0);
20 if (stbtt_InitFont(font_info_.get(), typeface_mapping_->GetMapping(),
21 offset) == 0) {
22 FML_LOG(ERROR) << "Failed to initialize stb font from binary data.";
23 } else {
24 is_valid_ = true;
25 }
26 }

## ◆ ~TypefaceSTB()

impeller::TypefaceSTB::~TypefaceSTB | ( |  | ) |
| override default

## Member Function Documentation

## ◆ GetFontInfo()

const stbtt_fontinfo * impeller::TypefaceSTB::GetFontInfo | ( |  | ) | const

Definition at line 50 of file typeface_stb.cc.

50 {
51 return font_info_.get();
52 }

## ◆ GetHash()

std::size_t impeller::TypefaceSTB::GetHash | ( |  | ) | const
| override

Definition at line 34 of file typeface_stb.cc.

34 {
35 if (!IsValid()) {
36 return 0u;
37 }
38 return reinterpret_cast<size_t>(typeface_mapping_->GetMapping());
39 }

References IsValid().

Referenced by IsEqual().

## ◆ GetTypefaceFile()

const uint8_t * impeller::TypefaceSTB::GetTypefaceFile | ( |  | ) | const

Definition at line 46 of file typeface_stb.cc.

46 {
47 return typeface_mapping_->GetMapping();
48 }

## ◆ IsEqual()

bool impeller::TypefaceSTB::IsEqual | ( | const Typeface & | other | ) | const
| override virtual

Implements impeller::Comparable< Typeface >.

Definition at line 41 of file typeface_stb.cc.

41 {
42 auto stb_other = reinterpret_cast<const TypefaceSTB*>(&other);
43 return stb_other->GetHash() == GetHash();
44 }

References GetHash().

## ◆ IsValid()

bool impeller::TypefaceSTB::IsValid | ( |  | ) | const
| override virtual

Implements impeller::Typeface.

Definition at line 30 of file typeface_stb.cc.

30 {
31 return is_valid_;
32 }

Referenced by GetHash().

## Member Data Documentation

## ◆ kPointsToPixels

constexpr float impeller::TypefaceSTB::kPointsToPixels = 96.0 / 72.0
| static constexpr

Definition at line 20 of file typeface_stb.h.

Referenced by impeller::CanAppendToExistingAtlas(), impeller::DrawGlyph(), impeller::MakeTextFrameSTB(), and impeller::PairsFitInAtlasOfSize().

The documentation for this class was generated from the following files:

- impeller/typographer/backends/stb/typeface_stb.h
- impeller/typographer/backends/stb/typeface_stb.cc

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::TypefaceSTB
TypefaceSTB(std::unique_ptr< fml::Mapping > typeface_mapping)
Definition: typeface_stb.cc:14