From 33755cc2e9fb6bf77cafe92389982c6bc116b332 Mon Sep 17 00:00:00 2001 From: Jaby Date: Wed, 3 Jan 2024 22:44:33 -0600 Subject: [PATCH] Support clearing existing text --- support/include/FontWriter/font_writer.hpp | 2 ++ support/src/FontWriter/src/font_writer.cpp | 6 +++++- 2 files changed, 7 insertions(+), 1 deletion(-) diff --git a/support/include/FontWriter/font_writer.hpp b/support/include/FontWriter/font_writer.hpp index 5f924b44..4232d3da 100644 --- a/support/include/FontWriter/font_writer.hpp +++ b/support/include/FontWriter/font_writer.hpp @@ -34,6 +34,8 @@ namespace JabyEngine { FontWriter::setup(vram_dst, Make::SizeI16(font_info.font_size.width, font_info.font_size.height)); } + void clear(); + void write(State& state, const char* str, ...) { __write_impl(str, GPU::Color24::Grey(), nullptr); } diff --git a/support/src/FontWriter/src/font_writer.cpp b/support/src/FontWriter/src/font_writer.cpp index 975dd083..74ae5d88 100644 --- a/support/src/FontWriter/src/font_writer.cpp +++ b/support/src/FontWriter/src/font_writer.cpp @@ -63,13 +63,17 @@ namespace JabyEngine { this->last_primitive = nullptr; } + void FontWriter :: clear() { + this->last_primitive = &this->tex_page[GPU::update_id()]; + } + void FontWriter :: write(State& state, const char* str, GPU::Color24 color, const Wiggle* wiggle, va_list list) { static const auto exchang_str = [](const char* str, const char* new_str) -> pair { return {str + 1, new_str}; }; if(!this->last_primitive) { - this->last_primitive = &this->tex_page[GPU::update_id()]; + FontWriter::clear(); } const auto row_count = 256/font_size.width;