MyGUI 3.5.3
MyGUI_FontData.h
Go to the documentation of this file.
1/*
2 * This source file is part of MyGUI. For the latest info, see http://mygui.info/
3 * Distributed under the MIT License
4 * (See accompanying file COPYING.MIT or copy at http://opensource.org/licenses/MIT)
5 */
6
7#ifndef MYGUI_FONT_DATA_H_
8#define MYGUI_FONT_DATA_H_
9
10#include "MyGUI_Prerequest.h"
11#include "MyGUI_Types.h"
12
13#include <unordered_map>
14#include <utility>
15
16namespace MyGUI
17{
18 namespace FontCodeType
19 {
20
22 {
23 Tab = 0x0009,
24 LF = 0x000A,
25 CR = 0x000D,
26 Space = 0x0020,
27 NEL = 0x0085,
28
29 // The following are special code points. These are used represent displayable text elements that do not correspond to
30 // any actual Unicode code point. To prevent collisions, they must be defined with values higher than that of the
31 // highest valid Unicode code point (0x10FFFF as of Unicode 6.1).
32 Selected = 0xFFFFFFFC, // Used for rendering text selections when they have input focus.
33 SelectedBack = 0xFFFFFFFD, // Used for rendering text selections when they don't have input focus.
34 Cursor = 0xFFFFFFFE, // Used for rendering the blinking text cursor.
36 0xFFFFFFFF // Used to render substitute glyphs for characters that aren't supported by the current font.
37 };
38
39 }
40
41 struct GlyphInfo
42 {
44 Char _codePoint = 0U,
45 float _width = 0.0f,
46 float _height = 0.0f,
47 float _advance = 0.0f,
48 float _bearingX = 0.0f,
49 float _bearingY = 0.0f,
50 const FloatRect& _uvRect = FloatRect()) :
51 codePoint(_codePoint),
52 width(_width),
53 height(_height),
54 advance(_advance),
55 bearingX(_bearingX),
56 bearingY(_bearingY),
57 uvRect(_uvRect)
58 {
59 }
60
62 float width;
63 float height;
64 float advance;
65 float bearingX;
66 float bearingY;
68 };
69
70 using VectorGlyphInfo = std::vector<GlyphInfo>;
71
73 {
74 size_t operator()(const std::pair<Char, Char>& p) const noexcept
75 {
76 // 32-bit fallback
77 if constexpr (sizeof(size_t) == 4)
78 return p.first ^ (p.second + 0x9e3779b9u + (p.first << 6) + (p.first >> 2));
79 return (static_cast<uint64_t>(p.first) << 32) | p.second;
80 }
81 };
82 // A map of kerning pairs (left code point, right code point) to kerning values in pixels.
83 using KerningMap = std::unordered_map<std::pair<Char, Char>, float, KerningPairHash>;
84
85} // namespace MyGUI
86
87#endif // MYGUI_FONT_DATA_H_
types::TRect< float > FloatRect
Definition MyGUI_Types.h:33
std::unordered_map< std::pair< Char, Char >, float, KerningPairHash > KerningMap
unsigned int Char
Definition MyGUI_Types.h:49
std::vector< GlyphInfo > VectorGlyphInfo
GlyphInfo(Char _codePoint=0U, float _width=0.0f, float _height=0.0f, float _advance=0.0f, float _bearingX=0.0f, float _bearingY=0.0f, const FloatRect &_uvRect=FloatRect())
size_t operator()(const std::pair< Char, Char > &p) const noexcept