From cc97f7bf4bee36e04bd42f527fa6eee09ad50f0c Mon Sep 17 00:00:00 2001 From: Yaroslav Tsarko Date: Fri, 27 May 2016 09:48:01 +0300 Subject: [PATCH 1/3] fixed 'unsigned short' overflow when drawing widget text with font size > widget height --- nuklear.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/nuklear.h b/nuklear.h index 894c900..0182eed 100644 --- a/nuklear.h +++ b/nuklear.h @@ -11259,7 +11259,7 @@ nk_widget_text(struct nk_command_buffer *o, struct nk_rect b, /* align in y-axis */ if (a & NK_TEXT_ALIGN_MIDDLE) { label.y = b.y + b.h/2.0f - (float)f->height/2.0f; - label.h = b.h - (b.h/2.0f + f->height/2.0f); + label.h = NK_MAX(b.h/2.0f, b.h - (b.h/2.0f + f->height/2.0f)); } else if (a & NK_TEXT_ALIGN_BOTTOM) { label.y = b.y + b.h - f->height; label.h = f->height; From de91bd6e03de5ca6665cbbdfa10e99a9eb03002c Mon Sep 17 00:00:00 2001 From: Yaroslav Tsarko Date: Fri, 27 May 2016 10:12:59 +0300 Subject: [PATCH 2/3] fixed compilation when 'NK_INCLUDE_VERTEX_BUFFER_OUTPUT' macro isn`t defined but 'NK_INCLUDE_FONT_BAKING' is --- nuklear.h | 2 ++ 1 file changed, 2 insertions(+) diff --git a/nuklear.h b/nuklear.h index 0182eed..7fd88da 100644 --- a/nuklear.h +++ b/nuklear.h @@ -9838,7 +9838,9 @@ nk_font_atlas_end(struct nk_font_atlas *atlas, nk_handle texture, } for (i = 0; i < atlas->font_num; ++i) { atlas->fonts[i]->texture = texture; +#ifdef NK_INCLUDE_VERTEX_BUFFER_OUTPUT atlas->fonts[i]->handle.texture = texture; +#endif } atlas->alloc.free(atlas->alloc.userdata, atlas->pixel); From 792a3af51ef546499f500af2949159ac76a257bb Mon Sep 17 00:00:00 2001 From: vurtun Date: Fri, 27 May 2016 11:29:42 +0200 Subject: [PATCH 3/3] Fixed property value drawing bug under xlib For some reason `xlib` still draws text even if the scissor rect has a width or height of `0`. I don't know if this is a bug on my end or on xlib but whatever the source it is now fixed. --- nuklear.h | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) diff --git a/nuklear.h b/nuklear.h index 7fd88da..5602251 100644 --- a/nuklear.h +++ b/nuklear.h @@ -5368,7 +5368,7 @@ nk_draw_image(struct nk_command_buffer *b, struct nk_rect r, if (!b) return; if (b->use_clipping) { const struct nk_rect *c = &b->clip; - if (!NK_INTERSECT(r.x, r.y, r.w, r.h, c->x, c->y, c->w, c->h)) + if (!c->w || !c->h || !NK_INTERSECT(r.x, r.y, r.w, r.h, c->x, c->y, c->w, c->h)) return; } @@ -5395,17 +5395,16 @@ nk_draw_text(struct nk_command_buffer *b, struct nk_rect r, if (!b || !string || !length || (bg.a == 0 && fg.a == 0)) return; if (b->use_clipping) { const struct nk_rect *c = &b->clip; - if (!NK_INTERSECT(r.x, r.y, r.w, r.h, c->x, c->y, c->w, c->h)) + if (!c->w || !c->h || !NK_INTERSECT(r.x, r.y, r.w, r.h, c->x, c->y, c->w, c->h)) return; } /* make sure text fits inside bounds */ text_width = font->width(font->userdata, font->height, string, length); if (text_width > r.w){ - float txt_width = (float)text_width; int glyphs = 0; - length = nk_text_clamp(font, string, length, - r.w, &glyphs, &txt_width); + float txt_width = (float)text_width; + length = nk_text_clamp(font, string, length, r.w, &glyphs, &txt_width); } if (!length) return;