@@ -23808,13 +23808,16 @@ nk_widget_text(struct nk_command_buffer *o, struct nk_rect b,
2380823808 if (!o || !t) return;
2380923809
2381023810 b.h = NK_MAX(b.h, 2 * t->padding.y);
23811- label.x = 0; label.w = 0;
23812- label.y = b.y + t->padding.y;
23813- label.h = NK_MIN(f->height, b.h - 2 * t->padding.y);
2381423811
2381523812 text_width = f->width(f->userdata, f->height, (const char*)string, len);
2381623813 text_width += (2.0f * t->padding.x);
2381723814
23815+ /* use top-left alignment by default */
23816+ if (!(a & (NK_TEXT_ALIGN_LEFT | NK_TEXT_ALIGN_CENTERED | NK_TEXT_ALIGN_RIGHT)))
23817+ a |= NK_TEXT_ALIGN_LEFT;
23818+ if (!(a & (NK_TEXT_ALIGN_TOP | NK_TEXT_ALIGN_MIDDLE | NK_TEXT_ALIGN_BOTTOM)))
23819+ a |= NK_TEXT_ALIGN_TOP;
23820+
2381823821 /* align in x-axis */
2381923822 if (a & NK_TEXT_ALIGN_LEFT) {
2382023823 label.x = b.x + t->padding.x;
@@ -23828,16 +23831,20 @@ nk_widget_text(struct nk_command_buffer *o, struct nk_rect b,
2382823831 } else if (a & NK_TEXT_ALIGN_RIGHT) {
2382923832 label.x = NK_MAX(b.x + t->padding.x, (b.x + b.w) - (2 * t->padding.x + (float)text_width));
2383023833 label.w = (float)text_width + 2 * t->padding.x;
23831- } else return;
23834+ }
2383223835
2383323836 /* align in y-axis */
23834- if (a & NK_TEXT_ALIGN_MIDDLE) {
23837+ if (a & NK_TEXT_ALIGN_TOP) {
23838+ label.y = b.y + t->padding.y;
23839+ label.h = NK_MIN(f->height, b.h - 2 * t->padding.y);
23840+ } else if (a & NK_TEXT_ALIGN_MIDDLE) {
2383523841 label.y = b.y + b.h/2.0f - (float)f->height/2.0f;
2383623842 label.h = NK_MAX(b.h/2.0f, b.h - (b.h/2.0f + f->height/2.0f));
2383723843 } else if (a & NK_TEXT_ALIGN_BOTTOM) {
2383823844 label.y = b.y + b.h - f->height;
2383923845 label.h = f->height;
2384023846 }
23847+
2384123848 nk_draw_text(o, label, (const char*)string, len, f, t->background, t->text);
2384223849}
2384323850NK_LIB void
@@ -30719,6 +30726,9 @@ nk_tooltipfv(struct nk_context *ctx, const char *fmt, va_list args)
3071930726/// - [y]: Minor version with non-breaking API and library changes
3072030727/// - [z]: Patch version with no direct changes to the API
3072130728///
30729+ /// - 2025/10/08 (4.12.8) - Fix nk_widget_text to use NK_TEXT_ALIGN_LEFT by default,
30730+ /// instead of silently failing when no x-axis alignment is provided,
30731+ /// and refactor this function to keep the code style consistent
3072230732/// - 2025/04/06 (4.12.7) - Fix text input navigation and mouse scrolling
3072330733/// - 2025/03/29 (4.12.6) - Fix unitialized data in nk_input_char
3072430734/// - 2025/03/05 (4.12.5) - Fix scrolling knob also scrolling parent window, remove dead code
0 commit comments