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, AxisAlignment axis_alignment)
 
 ~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
 
AxisAlignment GetAxisAlignment () const
 

Detailed Description

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

Definition at line 35 of file font.h.

Constructor & Destructor Documentation

◆ Font()

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

Definition at line 9 of file font.cc.

12  : typeface_(std::move(typeface)),
13  metrics_(metrics),
14  axis_alignment_(axis_alignment) {
15  if (!typeface_) {
16  return;
17  }
18  is_valid_ = true;
19 }

◆ ~Font()

impeller::Font::~Font ( )
default

Member Function Documentation

◆ GetAxisAlignment()

AxisAlignment impeller::Font::GetAxisAlignment ( ) const

Definition at line 41 of file font.cc.

41  {
42  return axis_alignment_;
43 }

Referenced by impeller::TextContents::ComputeVertexData().

◆ GetHash()

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

Implements impeller::Comparable< Font >.

Definition at line 31 of file font.cc.

31  {
32  return fml::HashCombine(is_valid_, typeface_ ? typeface_->GetHash() : 0u,
33  metrics_);
34 }

Referenced by impeller::TextShadowCache::TextShadowCacheKey::Hash::operator()().

◆ GetMetrics()

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

Definition at line 45 of file font.cc.

45  {
46  return metrics_;
47 }

Referenced by impeller::DrawGlyph().

◆ GetTypeface()

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

The typeface whose intrinsic properties this font modifies.

Returns
The typeface.

Definition at line 27 of file font.cc.

27  {
28  return typeface_;
29 }

Referenced by impeller::DrawGlyph().

◆ IsEqual()

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

Implements impeller::Comparable< Font >.

Definition at line 36 of file font.cc.

36  {
37  return DeepComparePointer(typeface_, other.typeface_) &&
38  is_valid_ == other.is_valid_ && metrics_ == other.metrics_;
39 }
bool DeepComparePointer(const std::shared_ptr< ComparableType > &lhs, const std::shared_ptr< ComparableType > &rhs)
Definition: comparable.h:57

References impeller::DeepComparePointer().

Referenced by impeller::ScaledFont::Equal::operator()(), and impeller::TextShadowCache::TextShadowCacheKey::Equal::operator()().

◆ IsValid()

bool impeller::Font::IsValid ( ) const

Definition at line 23 of file font.cc.

23  {
24  return is_valid_;
25 }

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


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