Flutter Impeller
font.cc
Go to the documentation of this file.
1 // Copyright 2013 The Flutter Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
4 
6 
7 namespace impeller {
8 
9 Font::Font(std::shared_ptr<Typeface> typeface,
10  Metrics metrics,
11  AxisAlignment axis_alignment)
12  : typeface_(std::move(typeface)),
13  metrics_(metrics),
14  axis_alignment_(axis_alignment) {
15  if (!typeface_) {
16  return;
17  }
18  is_valid_ = true;
19 }
20 
21 Font::~Font() = default;
22 
23 bool Font::IsValid() const {
24  return is_valid_;
25 }
26 
27 const std::shared_ptr<Typeface>& Font::GetTypeface() const {
28  return typeface_;
29 }
30 
31 std::size_t Font::GetHash() const {
32  return fml::HashCombine(is_valid_, typeface_ ? typeface_->GetHash() : 0u,
33  metrics_);
34 }
35 
36 bool Font::IsEqual(const Font& other) const {
37  return DeepComparePointer(typeface_, other.typeface_) &&
38  is_valid_ == other.is_valid_ && metrics_ == other.metrics_;
39 }
40 
42  return axis_alignment_;
43 }
44 
46  return metrics_;
47 }
48 
49 } // namespace impeller
Describes a typeface along with any modifications to its intrinsic properties.
Definition: font.h:35
bool IsEqual(const Font &other) const override
Definition: font.cc:36
const std::shared_ptr< Typeface > & GetTypeface() const
The typeface whose intrinsic properties this font modifies.
Definition: font.cc:27
AxisAlignment GetAxisAlignment() const
Definition: font.cc:41
std::size_t GetHash() const override
Definition: font.cc:31
const Metrics & GetMetrics() const
Definition: font.cc:45
Font(std::shared_ptr< Typeface > typeface, Metrics metrics, AxisAlignment axis_alignment)
Definition: font.cc:9
bool IsValid() const
Definition: font.cc:23
AxisAlignment
Determines the axis along which there is subpixel positioning.
Definition: font.h:20
bool DeepComparePointer(const std::shared_ptr< ComparableType > &lhs, const std::shared_ptr< ComparableType > &rhs)
Definition: comparable.h:57
Definition: comparable.h:95
Describes the modifications made to the intrinsic properties of a typeface.
Definition: font.h:44