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