Flutter Impeller
font_glyph_pair.h
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 #pragma once
6 
7 #include <optional>
8 #include <unordered_map>
9 #include <unordered_set>
10 #include <vector>
11 
12 #include "flutter/fml/macros.h"
13 #include "impeller/geometry/size.h"
16 
17 namespace impeller {
18 
19 //------------------------------------------------------------------------------
20 /// @brief A font and a scale. Used as a key that represents a typeface
21 /// within a glyph atlas.
22 ///
23 struct ScaledFont {
26 };
27 
28 using FontGlyphMap = std::unordered_map<ScaledFont, std::unordered_set<Glyph>>;
29 
30 //------------------------------------------------------------------------------
31 /// @brief A font along with a glyph in that font rendered at a particular
32 /// scale.
33 ///
34 struct FontGlyphPair {
35  FontGlyphPair(const ScaledFont& sf, const Glyph& g)
36  : scaled_font(sf), glyph(g) {}
38  const Glyph& glyph;
39 };
40 
41 } // namespace impeller
42 
43 template <>
44 struct std::hash<impeller::ScaledFont> {
45  constexpr std::size_t operator()(const impeller::ScaledFont& sf) const {
46  return fml::HashCombine(sf.font.GetHash(), sf.scale);
47  }
48 };
49 
50 template <>
51 struct std::equal_to<impeller::ScaledFont> {
52  constexpr bool operator()(const impeller::ScaledFont& lhs,
53  const impeller::ScaledFont& rhs) const {
54  return lhs.font.IsEqual(rhs.font) && lhs.scale == rhs.scale;
55  }
56 };
impeller::Font::GetHash
std::size_t GetHash() const override
Definition: font.cc:27
impeller::Scalar
float Scalar
Definition: scalar.h:15
std::hash< impeller::ScaledFont >::operator()
constexpr std::size_t operator()(const impeller::ScaledFont &sf) const
Definition: font_glyph_pair.h:45
impeller::Font
Describes a typeface along with any modifications to its intrinsic properties.
Definition: font.h:21
impeller::FontGlyphPair::FontGlyphPair
FontGlyphPair(const ScaledFont &sf, const Glyph &g)
Definition: font_glyph_pair.h:35
impeller::ScaledFont::font
Font font
Definition: font_glyph_pair.h:24
impeller::FontGlyphMap
std::unordered_map< ScaledFont, std::unordered_set< Glyph > > FontGlyphMap
Definition: font_glyph_pair.h:28
impeller::Glyph
The glyph index in the typeface.
Definition: glyph.h:19
impeller::FontGlyphPair::glyph
const Glyph & glyph
Definition: font_glyph_pair.h:38
glyph.h
impeller::FontGlyphPair::scaled_font
const ScaledFont & scaled_font
Definition: font_glyph_pair.h:37
font.h
impeller::FontGlyphPair
A font along with a glyph in that font rendered at a particular scale.
Definition: font_glyph_pair.h:34
impeller::ScaledFont::scale
Scalar scale
Definition: font_glyph_pair.h:25
impeller::Font::IsEqual
bool IsEqual(const Font &other) const override
Definition: font.cc:32
std::equal_to< impeller::ScaledFont >::operator()
constexpr bool operator()(const impeller::ScaledFont &lhs, const impeller::ScaledFont &rhs) const
Definition: font_glyph_pair.h:52
impeller
Definition: aiks_context.cc:10
impeller::ScaledFont
A font and a scale. Used as a key that represents a typeface within a glyph atlas.
Definition: font_glyph_pair.h:23
size.h