Flutter Engine
The Flutter Engine
Loading...
Searching...
No Matches
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
7namespace impeller {
8
9Font::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
17Font::~Font() = default;
18
19bool Font::IsValid() const {
20 return is_valid_;
21}
22
23const std::shared_ptr<Typeface>& Font::GetTypeface() const {
24 return typeface_;
25}
26
27std::size_t Font::GetHash() const {
28 return fml::HashCombine(is_valid_, typeface_ ? typeface_->GetHash() : 0u,
29 metrics_);
30}
31
32bool Font::IsEqual(const Font& other) const {
33 return DeepComparePointer(typeface_, other.typeface_) &&
34 is_valid_ == other.is_valid_ && metrics_ == other.metrics_;
35}
36
38 return metrics_;
39}
40
41} // namespace impeller
Describes a typeface along with any modifications to its intrinsic properties.
Definition font.h:22
Font(std::shared_ptr< Typeface > typeface, Metrics metrics)
Definition font.cc:9
bool IsEqual(const Font &other) const override
Definition font.cc:32
const std::shared_ptr< Typeface > & GetTypeface() const
The typeface whose intrinsic properties this font modifies.
Definition font.cc:23
std::size_t GetHash() const override
Definition font.cc:27
const Metrics & GetMetrics() const
Definition font.cc:37
bool IsValid() const
Definition font.cc:19
constexpr std::size_t HashCombine()
bool DeepComparePointer(const std::shared_ptr< ComparableType > &lhs, const std::shared_ptr< ComparableType > &rhs)
Definition comparable.h:57
Definition ref_ptr.h:256
Describes the modifications made to the intrinsic properties of a typeface.
Definition font.h:31