fix(render): give degenerate segments area, pin font bit order, clarify vertex_count

This commit is contained in:
Martino Ferrari committed 2026-09-27 22:10:53 +02:00
1 parent 7cbc1c9955
commit b4e88fe0c1
5 files changed
+76 -15

No files matched your search

+34
View File
@@ -151,6 +151,40 @@ PLOT_TEST(bitmap_font_decodes_si_units_and_falls_back_visibly) {
PLOT_CHECK(any_ink);
}
// The packed atlas must be left-to-right in absolute terms: `(row >> x) & 1` is
// also how every other expectation here is derived, so a table transcribed with
// the opposite in-row bit order would keep those tests green while drawing
// mirrored text. 'A' cannot catch that (it is
// symmetric about its vertical axis); 'L', 'b' and '/' can.
PLOT_TEST(bitmap_font_bit_order_runs_left_to_right) {
using plot::render::BitmapFont;
const plot::u8* atlas = BitmapFont::atlas_image();
auto ink = [atlas](char c, plot::u32 col, plot::u32 row) {
const plot::u32 slot = static_cast<plot::u32>(c) - BitmapFont::kFirstChar;
const plot::Vec2 origin = BitmapFont::atlas_origin(slot);
const auto x = static_cast<std::size_t>(origin.x) + col;
const auto y = static_cast<std::size_t>(origin.y) + row;
return atlas[y * BitmapFont::kAtlasWidth + x] != 0u;
};
// 'L': stem and top serif on the left, the foot running right along the
// bottom row and stopping one texel short of the right edge.
PLOT_CHECK(ink('L', 0u, 0u));
PLOT_CHECK(!ink('L', 7u, 0u));
PLOT_CHECK(ink('L', 1u, 3u));
PLOT_CHECK(!ink('L', 6u, 3u));
PLOT_CHECK(ink('L', 6u, 6u));
PLOT_CHECK(!ink('L', 7u, 6u));
// 'b': the stem is the leftmost column of the upper rows.
PLOT_CHECK(ink('b', 0u, 0u));
PLOT_CHECK(!ink('b', 7u, 0u));
// '/': starts at the right of the top row and ends at the left of the last
// one — the opposite of '\'.
PLOT_CHECK(ink('/', 6u, 0u));
PLOT_CHECK(!ink('/', 0u, 0u));
PLOT_CHECK(ink('/', 0u, 6u));
PLOT_CHECK(!ink('/', 6u, 6u));
}
PLOT_TEST(bitmap_font_atlas_is_uploadable) {
using plot::render::BitmapFont;
PLOT_CHECK(BitmapFont::kAtlasWidth == BitmapFont::kAtlasCols * BitmapFont::kGlyphPx);