HikoGUI
A low latency retained GUI
Loading...
Searching...
No Matches
glyph_metrics.hpp
1// Copyright Take Vos 2019-2021.
2// Distributed under the Boost Software License, Version 1.0.
3// (See accompanying file LICENSE_1_0.txt or copy at https://www.boost.org/LICENSE_1_0.txt)
4
5#pragma once
6
7#include "../required.hpp"
8#include "../geometry/axis_aligned_rectangle.hpp"
9#include "../geometry/scale.hpp"
10
11namespace tt {
12
21
28 float leftSideBearing = 0.0f;
29
34 float rightSideBearing = 0.0f;
35
38 float ascender = 0.0f;
39
42 float descender = 0.0f;
43
46 float lineGap = 0.0f;
47
50 float capHeight = 0.0f;
51
54 float xHeight = 0.0f;
55
58 vector2 advance = {0.0f, 0.0f};
59
64
65 glyph_metrics() noexcept = default;
66 glyph_metrics(glyph_metrics const &) noexcept = default;
67 glyph_metrics(glyph_metrics &&) noexcept = default;
68 glyph_metrics &operator=(glyph_metrics const &) noexcept = default;
69 glyph_metrics &operator=(glyph_metrics &&) noexcept = default;
70
74 vector2 advanceForgrapheme(int index) const noexcept {
75 ttlet ligatureRatio = 1.0f / numberOfgraphemes;
76
77 return advance * ligatureRatio * narrow_cast<float>(index);
78 }
79
80 glyph_metrics &scale(float rhs) noexcept
81 {
82 auto S = scale2(rhs);
83
85 leftSideBearing *= rhs;
86 rightSideBearing *= rhs;
87 advance = S * advance;
88 ascender *= rhs;
89 descender *= rhs;
90 lineGap *= rhs;
91 capHeight *= rhs;
92 xHeight *= rhs;
93 return *this;
94 }
95};
96
97
98
99}
Class which represents an axis-aligned rectangle.
Definition axis_aligned_rectangle.hpp:18
Definition scale.hpp:15
Definition glyph_metrics.hpp:17
float rightSideBearing
Definition glyph_metrics.hpp:34
aarectangle boundingBox
Definition glyph_metrics.hpp:20
float leftSideBearing
Definition glyph_metrics.hpp:28
float descender
Definition glyph_metrics.hpp:42
vector2 advance
Definition glyph_metrics.hpp:58
float lineGap
Definition glyph_metrics.hpp:46
float capHeight
Definition glyph_metrics.hpp:50
float xHeight
Definition glyph_metrics.hpp:54
int numberOfgraphemes
Definition glyph_metrics.hpp:63
float ascender
Definition glyph_metrics.hpp:38
vector2 advanceForgrapheme(int index) const noexcept
Definition glyph_metrics.hpp:74