7#include "resource/asset/font_asset.h"
27template <
typename Visit>
28float walkGlyphs(
const FontAsset& font, std::string_view text,
float scale, Visit&& visit) {
32 while (at < text.size()) {
33 const std::size_t start = at;
39 if (previous >= 0) pen += font.kern(previous, index) * scale;
41 const FontGlyph& glyph = font.glyphs[
static_cast<std::size_t
>(index)];
42 if (!visit(start, glyph, pen))
return pen;
57inline float measureText(
const FontAsset& font, std::string_view text,
float pixelSize) {
58 if (font.pixelHeight <= 0.0f)
return 0.0f;
62 pixelSize / font.pixelHeight,
63 [](std::size_t,
const FontGlyph&,
float) { return true; }
A TrueType font baked to a signed-distance-field atlas.
Definition font_asset.h:48
static constexpr int glyphIndex(char32_t codepoint)
Where codepoint sits in the glyph table.
Definition font_asset.h:106
One glyph's atlas placement and layout metrics, in baked pixels.
Definition font_asset.h:21
float advance
Pen advance in baked pixels.
Definition font_asset.h:27