Flutter Engine
The Flutter Engine
Loading...
Searching...
No Matches
Public Member Functions | Static Public Attributes | List of all members
impeller::TypefaceSTB Class Referencefinal

#include <typeface_stb.h>

Inheritance diagram for impeller::TypefaceSTB:
impeller::Typeface impeller::BackendCast< TypefaceSTB, Typeface > impeller::Comparable< Typeface > impeller::ComparableBase

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 ()
 

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 TypefaceSTBCast (Typeface &base)
 
static const TypefaceSTBCast (const Typeface &base)
 
static TypefaceSTBCast (Typeface *base)
 
static const TypefaceSTBCast (const Typeface *base)
 

Detailed Description

Definition at line 16 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}
#define FML_LOG(severity)
Definition logging.h:82
Point offset
#define ERROR(message)

◆ ~TypefaceSTB()

impeller::TypefaceSTB::~TypefaceSTB ( )
overridedefault

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
overridevirtual

Implements impeller::Comparable< Typeface >.

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}
bool IsValid() const override

◆ 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
overridevirtual

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}
std::size_t GetHash() const override
TypefaceSTB(std::unique_ptr< fml::Mapping > typeface_mapping)

◆ IsValid()

bool impeller::TypefaceSTB::IsValid ( ) const
overridevirtual

Implements impeller::Typeface.

Definition at line 29 of file typeface_stb.cc.

29 {
30 return is_valid_;
31}

Member Data Documentation

◆ kPointsToPixels

constexpr float impeller::TypefaceSTB::kPointsToPixels = 96.0 / 72.0
staticconstexpr

Definition at line 21 of file typeface_stb.h.


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