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 "../numeric_array.hpp"
9#include "../aarect.hpp"
10#include "../geometry/scale.hpp"
11
12namespace tt {
13
22
29 float leftSideBearing = 0.0f;
30
35 float rightSideBearing = 0.0f;
36
39 float ascender = 0.0f;
40
43 float descender = 0.0f;
44
47 float lineGap = 0.0f;
48
51 float capHeight = 0.0f;
52
55 float xHeight = 0.0f;
56
59 f32x4 advance = {0.0f, 0.0f};
60
65
66 glyph_metrics() noexcept = default;
67 glyph_metrics(glyph_metrics const &) noexcept = default;
68 glyph_metrics(glyph_metrics &&) noexcept = default;
69 glyph_metrics &operator=(glyph_metrics const &) noexcept = default;
70 glyph_metrics &operator=(glyph_metrics &&) noexcept = default;
71
75 f32x4 advanceForgrapheme(int index) const noexcept {
76 ttlet ligatureRatio = 1.0f / numberOfgraphemes;
77
78 return advance * ligatureRatio * narrow_cast<float>(index);
79 }
80
81 glyph_metrics &scale(float rhs) noexcept
82 {
83 auto S = scale2(rhs);
84
86 leftSideBearing *= rhs;
87 rightSideBearing *= rhs;
88 advance = S * advance;
89 ascender *= rhs;
90 descender *= rhs;
91 lineGap *= rhs;
92 capHeight *= rhs;
93 xHeight *= rhs;
94 return *this;
95 }
96};
97
98
99
100}
Definition scale.hpp:15
Definition glyph_metrics.hpp:18
f32x4 advance
Definition glyph_metrics.hpp:59
float rightSideBearing
Definition glyph_metrics.hpp:35
float leftSideBearing
Definition glyph_metrics.hpp:29
float descender
Definition glyph_metrics.hpp:43
float lineGap
Definition glyph_metrics.hpp:47
float capHeight
Definition glyph_metrics.hpp:51
aarect boundingBox
Definition glyph_metrics.hpp:21
float xHeight
Definition glyph_metrics.hpp:55
int numberOfgraphemes
Definition glyph_metrics.hpp:64
float ascender
Definition glyph_metrics.hpp:39
f32x4 advanceForgrapheme(int index) const noexcept
Definition glyph_metrics.hpp:75