7#include "../macros.hpp"
8#include "../units/units.hpp"
12hi_export_module(hikogui.font.font_metrics);
14hi_export
namespace hi::inline
v1 {
21template<
typename Unit,
typename T>
56 float line_spacing = 0.0f;
61 float paragraph_spacing = 0.0f;
73 template<typename LhsUnit, typename LhsT>
74 [[nodiscard]] constexpr friend auto operator*(au::Quantity<LhsUnit, LhsT> const& lhs,
font_metrics const& rhs) noexcept requires
std::same_as<Unit, EmSquares>
78 std::conditional_t<std::is_same_v<LhsUnit, PixelsPerEm>, Pixels,
79 std::conditional_t<std::is_same_v<LhsUnit, PointsPerEm>, Points,
80 std::conditional_t<std::is_same_v<LhsUnit, DipsPerEm>, Dips,
86 r.descender = lhs * rhs.descender;
87 r.line_gap = lhs * rhs.line_gap;
88 r.cap_height = lhs * rhs.cap_height;
89 r.x_height = lhs * rhs.x_height;
90 r.digit_advance = lhs * rhs.digit_advance;
91 r.line_spacing = rhs.line_spacing;
92 r.paragraph_spacing = rhs.paragraph_spacing;
100 r.descender =
std::max(a.descender, b.descender);
101 r.line_gap =
std::max(a.line_gap, b.line_gap);
102 r.cap_height =
std::max(a.cap_height, b.cap_height);
103 r.x_height =
std::max(a.x_height, b.x_height);
104 r.digit_advance =
std::max(a.digit_advance, b.digit_advance);
105 r.line_spacing =
std::max(a.line_spacing, b.line_spacing);
106 r.paragraph_spacing =
std::max(a.paragraph_spacing, b.paragraph_spacing);
111using font_metrics_em = font_metrics<EmSquares, float>;
112using font_metrics_pt = font_metrics<Points, float>;
113using font_metrics_px = font_metrics<Pixels, float>;
DOXYGEN BUG.
Definition algorithm_misc.hpp:20
The metrics of a font.
Definition font_metrics.hpp:22
au::Quantity< Unit, T > ascender
Distance from baseline of highest ascender.
Definition font_metrics.hpp:25
au::Quantity< Unit, T > line_gap
Distance between lines.
Definition font_metrics.hpp:37
au::Quantity< Unit, T > descender
Distance from baseline of lowest descender.
Definition font_metrics.hpp:31
au::Quantity< Unit, T > cap_height
Height of capital letter, or height of the letter 'H'.
Definition font_metrics.hpp:41
au::Quantity< Unit, T > x_height
Height of lower case characters without ascenders or descenders, or the small letter 'x'.
Definition font_metrics.hpp:45
au::Quantity< Unit, T > digit_advance
The advance for digits, specifically the digit '8'.
Definition font_metrics.hpp:51