Flutter Impeller
typeface_skia.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 TypefaceSkia::TypefaceSkia(sk_sp<SkTypeface> typeface)
10  : typeface_(std::move(typeface)) {}
11 
12 TypefaceSkia::~TypefaceSkia() = default;
13 
14 bool TypefaceSkia::IsValid() const {
15  return !!typeface_;
16 }
17 
18 std::size_t TypefaceSkia::GetHash() const {
19  if (!IsValid()) {
20  return 0u;
21  }
22 
23  return reinterpret_cast<size_t>(typeface_.get());
24 }
25 
26 bool TypefaceSkia::IsEqual(const Typeface& other) const {
27  auto sk_other = reinterpret_cast<const TypefaceSkia*>(&other);
28  return sk_other->typeface_ == typeface_;
29 }
30 
31 const sk_sp<SkTypeface>& TypefaceSkia::GetSkiaTypeface() const {
32  return typeface_;
33 }
34 
35 } // namespace impeller
A typeface, usually obtained from a font-file, on disk describes the intrinsic properties of the font...
Definition: typeface.h:18
TypefaceSkia(sk_sp< SkTypeface > typeface)
Definition: typeface_skia.cc:9
std::size_t GetHash() const override
const sk_sp< SkTypeface > & GetSkiaTypeface() const
bool IsEqual(const Typeface &other) const override
bool IsValid() const override
Definition: comparable.h:95