26.6 fixed point
text_font_measure_run, text_font_ascent26, text_font_descent26, text_font_line_height26 and text_font_underline26 work in 26.6 fixed point: an int32_t with six fractional bits.
This is the surface the deck baker mirrors bit for bit, so a baked layout never drifts a pixel from what the engine draws at runtime. Use it wherever a result has to agree with a bake, such as layout proofs. The float calls are fine everywhere else.
text_fixed_point.cpp
#include "isolenui/text/text_font.h"
// 26.6 fixed point, six fractional bits, the surface the deck baker mirrors
// bit for bit so a bake never drifts a pixel from what the engine draws
static int32_t to_26_6(float v)
{
return int32_t(v * 64.0f);
}
static void measure_run_26_6(const text_font* f, const char* utf8)
{
const uint32_t face = 0u;
const int32_t px26 = to_26_6(16.0f);
const int32_t tracking26 = 0;
const int32_t width26 =
text_font_measure_run(f, face, utf8, TEXT_FONT_TERMINATED, px26,
tracking26);
const int32_t ascent26 = text_font_ascent26(f, face, px26);
const int32_t descent26 = text_font_descent26(f, face, px26);
const int32_t line_h26 = text_font_line_height26(f, face, px26);
int32_t underline_off26 = 0;
int32_t underline_th26 = 0;
text_font_underline26(f, face, px26, &underline_off26, &underline_th26);
(void)width26;
(void)ascent26;
(void)descent26;
(void)line_h26;
(void)underline_off26;
(void)underline_th26;
}