HikoGUI
A low latency retained GUI
Loading...
Searching...
No Matches
GlyphMetrics.hpp
1// Copyright 2019, 2020 Pokitec
2// All rights reserved.
3
4#pragma once
5
6#include "TTauri/Foundation/required.hpp"
7#include "TTauri/Foundation/vec.hpp"
8#include "TTauri/Foundation/mat.hpp"
9#include "TTauri/Foundation/aarect.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 vec advance = {0.0f, 0.0f};
59
64
65 GlyphMetrics() noexcept = default;
66 GlyphMetrics(GlyphMetrics const &) noexcept = default;
67 GlyphMetrics(GlyphMetrics &&) noexcept = default;
68 GlyphMetrics &operator=(GlyphMetrics const &) noexcept = default;
69 GlyphMetrics &operator=(GlyphMetrics &&) noexcept = default;
70
74 vec advanceForGrapheme(int index) const noexcept {
75 ttlet ligatureRatio = vec{1.0f / numberOfGraphemes};
76
77 return advance * ligatureRatio * vec{index};
78 }
79
80 GlyphMetrics &scale(float rhs) noexcept
81 {
82 auto S = mat::S(rhs, 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 aarect.hpp:13
Optimized scale matrix.
Definition mat.hpp:56
A 4D vector.
Definition vec.hpp:37
Definition GlyphMetrics.hpp:17
float xHeight
Definition GlyphMetrics.hpp:54
float ascender
Definition GlyphMetrics.hpp:38
float descender
Definition GlyphMetrics.hpp:42
int numberOfGraphemes
Definition GlyphMetrics.hpp:63
vec advanceForGrapheme(int index) const noexcept
Definition GlyphMetrics.hpp:74
float leftSideBearing
Definition GlyphMetrics.hpp:28
float rightSideBearing
Definition GlyphMetrics.hpp:34
vec advance
Definition GlyphMetrics.hpp:58
float capHeight
Definition GlyphMetrics.hpp:50
float lineGap
Definition GlyphMetrics.hpp:46
aarect boundingBox
Definition GlyphMetrics.hpp:20