| 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,
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
41 AxisAlignment Font::GetAxisAlignment() const {
42 return axis_alignment_;
43 }
44
45 const Font::Metrics& Font::GetMetrics() const {
46 return metrics_;
47 }
48
49 } // namespace impeller
impeller::DeepComparePointer
bool DeepComparePointer(const std::shared_ptr< ComparableType > &lhs, const std::shared_ptr< ComparableType > &rhs)
Definition: comparable.h:57
impeller::Font::GetHash
std::size_t GetHash() const override
Definition: font.cc:31
impeller::Font
Describes a typeface along with any modifications to its intrinsic properties.
Definition: font.h:35
impeller::Font::~Font
~Font()
impeller::Font::IsValid
bool IsValid() const
Definition: font.cc:23
impeller::Font::GetTypeface
const std::shared_ptr< Typeface > & GetTypeface() const
The typeface whose intrinsic properties this font modifies.
Definition: font.cc:27
font.h
impeller::Font::Font
Font(std::shared_ptr< Typeface > typeface, Metrics metrics, AxisAlignment axis_alignment)
Definition: font.cc:9
impeller::AxisAlignment
AxisAlignment
Determines the axis along which there is subpixel positioning.
Definition: font.h:20
impeller::Font::GetMetrics
const Metrics & GetMetrics() const
Definition: font.cc:45
std
Definition: comparable.h:95
impeller::Font::IsEqual
bool IsEqual(const Font &other) const override
Definition: font.cc:36
impeller
Definition: aiks_blend_unittests.cc:18
impeller::Font::Metrics
Describes the modifications made to the intrinsic properties of a typeface.
Definition: font.h:44
impeller::Font::GetAxisAlignment
AxisAlignment GetAxisAlignment() const
Definition: font.cc:41