| 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
5 #include "impeller/typographer/font.h"
6
7 namespace impeller {
8
9 Font::Font(std::shared_ptr<Typeface> typeface, Metrics metrics)
10 : typeface_(std::move(typeface)), metrics_(metrics) {
11 if (!typeface_) {
12 return;
13 }
14 is_valid_ = true;
15 }
16
17 Font::~Font() = default;
18
19 bool Font::IsValid() const {
20 return is_valid_;
21 }
22
23 const std::shared_ptr<Typeface>& Font::GetTypeface() const {
24 return typeface_;
25 }
26
27 std::size_t Font::GetHash() const {
28 return fml::HashCombine(is_valid_, typeface_ ? typeface_->GetHash() : 0u,
29 metrics_);
30 }
31
32 bool Font::IsEqual(const Font& other) const {
33 return DeepComparePointer(typeface_, other.typeface_) &&
34 is_valid_ == other.is_valid_ && metrics_ == other.metrics_;
35 }
36
37 const Font::Metrics& Font::GetMetrics() const {
38 return metrics_;
39 }
40
41 } // namespace impeller
impeller::DeepComparePointer
bool DeepComparePointer(const std::shared_ptr< ComparableType > &lhs, const std::shared_ptr< ComparableType > &rhs)
Definition: comparable.h:60
impeller::Font::GetHash
std::size_t GetHash() const override
Definition: font.cc:27
impeller::Font
Describes a typeface along with any modifications to its intrinsic properties.
Definition: font.h:21
impeller::Font::~Font
~Font()
impeller::Font::Font
Font(std::shared_ptr< Typeface > typeface, Metrics metrics)
Definition: font.cc:9
impeller::Font::IsValid
bool IsValid() const
Definition: font.cc:19
impeller::Font::GetTypeface
const std::shared_ptr< Typeface > & GetTypeface() const
The typeface whose intrinsic properties this font modifies.
Definition: font.cc:23
font.h
impeller::Font::GetMetrics
const Metrics & GetMetrics() const
Definition: font.cc:37
std
Definition: comparable.h:98
impeller::Font::IsEqual
bool IsEqual(const Font &other) const override
Definition: font.cc:32
impeller
Definition: aiks_context.cc:10
impeller::Font::Metrics
Describes the modifications made to the intrinsic properties of a typeface.
Definition: font.h:30