| 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 // We need an "offset" into the ttf file
18 auto offset = stbtt_GetFontOffsetForIndex(typeface_mapping_->GetMapping(), 0);
19 if (stbtt_InitFont(font_info_.get(), typeface_mapping_->GetMapping(),
20 offset) == 0) {
21 FML_LOG(ERROR) << "Failed to initialize stb font from binary data.";
22 } else {
23 is_valid_ = true;
24 }
25 }

References offset.

## ◆ ~TypefaceSTB()

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

## Member Function Documentation

## ◆ GetFontInfo()

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

Definition at line 49 of file typeface_stb.cc.

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

## ◆ GetHash()

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

Definition at line 33 of file typeface_stb.cc.

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

References IsValid().

Referenced by IsEqual().

## ◆ GetTypefaceFile()

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

Definition at line 45 of file typeface_stb.cc.

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

## ◆ IsEqual()

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

Implements impeller::Comparable< Typeface >.

Definition at line 40 of file typeface_stb.cc.

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

References GetHash().

## ◆ IsValid()

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

Implements impeller::Typeface.

Definition at line 29 of file typeface_stb.cc.

29 {
30 return is_valid_;
31 }

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::ComputeGlyphSize(), 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:33
offset
SeparatedVector2 offset
Definition: stroke_path_geometry.cc:304
impeller::TypefaceSTB::IsValid
bool IsValid() const override
Definition: typeface_stb.cc:29
impeller::TypefaceSTB::TypefaceSTB
TypefaceSTB(std::unique_ptr< fml::Mapping > typeface_mapping)
Definition: typeface_stb.cc:14