Antkeeper  0.0.1
font.hpp
Go to the documentation of this file.
1 /*
2  * Copyright (C) 2023 Christopher J. Howard
3  *
4  * This file is part of Antkeeper source code.
5  *
6  * Antkeeper source code is free software: you can redistribute it and/or modify
7  * it under the terms of the GNU General Public License as published by
8  * the Free Software Foundation, either version 3 of the License, or
9  * (at your option) any later version.
10  *
11  * Antkeeper source code is distributed in the hope that it will be useful,
12  * but WITHOUT ANY WARRANTY; without even the implied warranty of
13  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14  * GNU General Public License for more details.
15  *
16  * You should have received a copy of the GNU General Public License
17  * along with Antkeeper source code. If not, see <http://www.gnu.org/licenses/>.
18  */
19 
20 #ifndef ANTKEEPER_TYPE_FONT_HPP
21 #define ANTKEEPER_TYPE_FONT_HPP
22 
26 
27 namespace type {
28 
36 class font
37 {
38 public:
44  font(const font_metrics& metrics);
45 
47  font();
48 
50  virtual ~font();
51 
58  virtual bool contains(char32_t code) const = 0;
59 
67  void kern(char32_t first, char32_t second, const math::fvec2& offset);
68 
75 
82  virtual const glyph_metrics& get_glyph_metrics(char32_t code) const = 0;
83 
91  const math::fvec2& get_kerning(char32_t first, char32_t second) const;
92 
94  const kerning_table& get_kerning_table() const;
95 
97  const font_metrics& get_font_metrics() const;
98 
99 protected:
102 };
103 
105 {
106  return kerning_table;
107 }
108 
110 {
111  return metrics;
112 }
113 
114 } // namespace type
115 
116 #endif // ANTKEEPER_TYPE_FONT_HPP
Abstract base class for fonts.
Definition: font.hpp:37
const math::fvec2 & get_kerning(char32_t first, char32_t second) const
Returns the kerning offset for a pair of glyphs.
Definition: font.cpp:44
virtual bool contains(char32_t code) const =0
Returns true if the font contains a glyph with the given character code.
font_metrics metrics
Definition: font.hpp:100
void set_font_metrics(const font_metrics &metrics)
Sets the font metrics.
Definition: font.cpp:39
font()
Creates an empty font.
Definition: font.cpp:28
void kern(char32_t first, char32_t second, const math::fvec2 &offset)
Sets the kerning offset for a pair of glyphs.
Definition: font.cpp:34
const kerning_table & get_kerning_table() const
Returns the font's kerning table.
Definition: font.hpp:104
kerning_table kerning_table
Definition: font.hpp:101
virtual const glyph_metrics & get_glyph_metrics(char32_t code) const =0
Returns metrics describing a glyph.
const font_metrics & get_font_metrics() const
Returns metrics describing the font.
Definition: font.hpp:109
virtual ~font()
Destroys a font.
Definition: font.cpp:31
T offset(T longitude)
Calculates the UTC offset at a given longitude.
Definition: utc.hpp:38
Text and typography.
Definition: bitmap-font.cpp:24
std::unordered_map< char32_t, std::unordered_map< char32_t, math::fvec2 > > kerning_table
Table containing kerning offsets for pairs of glyphs.
n-dimensional vector.
Definition: vector.hpp:44
Metrics describing properties of a font.
Metrics describing properties of a glyph.