From fafafd98ee49225200fe0f48726e00c2be4f3dbf Mon Sep 17 00:00:00 2001 From: Rob Loach Date: Sat, 14 Sep 2024 14:52:59 -0400 Subject: [PATCH] Add font styling --- nuklear_console.h | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) diff --git a/nuklear_console.h b/nuklear_console.h index 16ce80e..fe9c1df 100644 --- a/nuklear_console.h +++ b/nuklear_console.h @@ -99,6 +99,9 @@ typedef struct nk_console { // Events nk_console_event_handler* events; /** Events handled for the widget. */ nk_console_render_event render; /** Render the widget. */ + + // Styles + const struct nk_user_font *font; } nk_console; typedef struct nk_console_top_data { @@ -682,6 +685,11 @@ NK_API void nk_console_render(nk_console* console) { return; } + // Push any styles. + if (console->font != NULL) { + nk_style_push_font(console->ctx, console->font); + } + // First run on this game loop if (console->parent == NULL) { nk_console_top_data* data = (nk_console_top_data*)console->data; @@ -741,12 +749,22 @@ NK_API void nk_console_render(nk_console* console) { cvector_clear(console->events); } } + + // Finish the styles. + if (console->font != NULL) { + nk_style_pop_font(console->ctx); + } return; } // Render the widget and get its bounds. struct nk_rect widget_bounds = console->render != NULL ? console->render(console) : nk_rect(0, 0, 0, 0); + // Finish the styles. + if (console->font != NULL) { + nk_style_pop_font(console->ctx); + } + // Allow the mouse to switch focus to the widget. if (widget_bounds.w > 0 && widget_bounds.h > 0 && nk_input_is_mouse_moved(&console->ctx->input)) { // Make sure we consider the active scroll position of the window.