Flutter Impeller
impeller::Font Class Reference

Describes a typeface along with any modifications to its intrinsic properties. More...

#include <font.h>

Inheritance diagram for impeller::Font:
impeller::Comparable< Font > impeller::ComparableBase

Classes

struct  Metrics
 Describes the modifications made to the intrinsic properties of a typeface. More...
 

Public Member Functions

 Font (std::shared_ptr< Typeface > typeface, Metrics metrics)
 
 ~Font ()
 
bool IsValid () const
 
const std::shared_ptr< Typeface > & GetTypeface () const
 The typeface whose intrinsic properties this font modifies. More...
 
const MetricsGetMetrics () const
 
std::size_t GetHash () const override
 
bool IsEqual (const Font &other) const override
 
- Public Member Functions inherited from impeller::Comparable< Font >
virtual std::size_t GetHash () const=0
 

Detailed Description

Describes a typeface along with any modifications to its intrinsic properties.

Definition at line 22 of file font.h.

Constructor & Destructor Documentation

◆ Font()

impeller::Font::Font ( std::shared_ptr< Typeface typeface,
Metrics  metrics 
)

Definition at line 9 of file font.cc.

10  : typeface_(std::move(typeface)), metrics_(metrics) {
11  if (!typeface_) {
12  return;
13  }
14  is_valid_ = true;
15 }

◆ ~Font()

impeller::Font::~Font ( )
default

Member Function Documentation

◆ GetHash()

std::size_t impeller::Font::GetHash ( ) const
override

Definition at line 27 of file font.cc.

27  {
28  return fml::HashCombine(is_valid_, typeface_ ? typeface_->GetHash() : 0u,
29  metrics_);
30 }

Referenced by std::hash< impeller::ScaledFont >::operator()().

◆ GetMetrics()

const Font::Metrics & impeller::Font::GetMetrics ( ) const

◆ GetTypeface()

const std::shared_ptr< Typeface > & impeller::Font::GetTypeface ( ) const

The typeface whose intrinsic properties this font modifies.

Returns
The typeface.

Definition at line 23 of file font.cc.

23  {
24  return typeface_;
25 }

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

◆ IsEqual()

bool impeller::Font::IsEqual ( const Font other) const
overridevirtual

Implements impeller::Comparable< Font >.

Definition at line 32 of file font.cc.

32  {
33  return DeepComparePointer(typeface_, other.typeface_) &&
34  is_valid_ == other.is_valid_ && metrics_ == other.metrics_;
35 }

References impeller::DeepComparePointer().

Referenced by std::equal_to< impeller::ScaledFont >::operator()().

◆ IsValid()

bool impeller::Font::IsValid ( ) const

Definition at line 19 of file font.cc.

19  {
20  return is_valid_;
21 }

Referenced by impeller::TextRun::TextRun().


The documentation for this class was generated from the following files:
impeller::DeepComparePointer
bool DeepComparePointer(const std::shared_ptr< ComparableType > &lhs, const std::shared_ptr< ComparableType > &rhs)
Definition: comparable.h:57