diff --git a/example/filex/filex.c b/example/filex/filex.c index b869b94..606e0d9 100644 --- a/example/filex/filex.c +++ b/example/filex/filex.c @@ -616,14 +616,15 @@ file_browser_run(struct file_browser *browser, int width, int height) * APP * * ================================================================= */ -static zr_size -font_get_width(zr_handle handle, const char *text, zr_size len) +static size_t +font_get_width(zr_handle handle, float height, const char *text, size_t len) { - zr_size width; + size_t width; float bounds[4]; NVGcontext *ctx = (NVGcontext*)handle.ptr; + nvgFontSize(ctx, (float)height); nvgTextBounds(ctx, 0, 0, text, &text[len], bounds); - width = (zr_size)(bounds[2] - bounds[0]); + width = (size_t)(bounds[2] - bounds[0]); return width; } @@ -700,6 +701,7 @@ draw(NVGcontext *nvg, struct zr_command_queue *queue, int width, int height) nvgBeginPath(nvg); nvgFillColor(nvg, nvgRGBA(t->foreground.r, t->foreground.g, t->foreground.b, t->foreground.a)); + nvgFontSize(nvg, (float)t->height); nvgTextAlign(nvg, NVG_ALIGN_MIDDLE); nvgText(nvg, t->x, t->y + t->h * 0.5f, t->string, &t->string[t->length]); nvgFill(nvg); @@ -829,7 +831,7 @@ main(int argc, char *argv[]) if (!vg) die("[NVG]: failed to init\n"); nvgCreateFont(vg, "fixed", font_path); nvgFontFace(vg, "fixed"); - nvgFontSize(vg, 10); + nvgFontSize(vg, 14); nvgTextAlign(vg, NVG_ALIGN_LEFT|NVG_ALIGN_MIDDLE); /* GUI */ diff --git a/example/nodedit/nodedit.c b/example/nodedit/nodedit.c index 66ccef6..77675bf 100644 --- a/example/nodedit/nodedit.c +++ b/example/nodedit/nodedit.c @@ -435,14 +435,15 @@ die(const char *fmt, ...) exit(EXIT_FAILURE); } -static zr_size -font_get_width(zr_handle handle, const char *text, zr_size len) +static size_t +font_get_width(zr_handle handle, float height, const char *text, size_t len) { - zr_size width; + size_t width; float bounds[4]; NVGcontext *ctx = (NVGcontext*)handle.ptr; + nvgFontSize(ctx, (float)height); nvgTextBounds(ctx, 0, 0, text, &text[len], bounds); - width = (zr_size)(bounds[2] - bounds[0]); + width = (size_t)(bounds[2] - bounds[0]); return width; } @@ -519,6 +520,7 @@ draw(NVGcontext *nvg, struct zr_command_queue *queue, int width, int height) nvgBeginPath(nvg); nvgFillColor(nvg, nvgRGBA(t->foreground.r, t->foreground.g, t->foreground.b, t->foreground.a)); + nvgFontSize(nvg, (float)t->height); nvgTextAlign(nvg, NVG_ALIGN_MIDDLE); nvgText(nvg, t->x, t->y + t->h * 0.5f, t->string, &t->string[t->length]); nvgFill(nvg); @@ -627,7 +629,7 @@ main(int argc, char *argv[]) exit(EXIT_FAILURE); } font_path = argv[1]; - font_height = 12; + font_height = 14; /* SDL */ SDL_Init(SDL_INIT_VIDEO|SDL_INIT_TIMER|SDL_INIT_EVENTS);