diff --git a/src/nanovg.c b/src/nanovg.c index bcd5bca..44b8eb8 100644 --- a/src/nanovg.c +++ b/src/nanovg.c @@ -2116,7 +2116,6 @@ int nvgTextGlyphPositions(struct NVGcontext* ctx, float x, float y, const char* struct FONStextIter iter; struct FONSquad q; int npos = 0; - float px; if (state->fontId == FONS_INVALID) return 0; @@ -2132,12 +2131,12 @@ int nvgTextGlyphPositions(struct NVGcontext* ctx, float x, float y, const char* fonsSetAlign(ctx->fs, state->textAlign); fonsSetFont(ctx->fs, state->fontId); - px = x*scale; fonsTextIterInit(ctx->fs, &iter, x*scale, y*scale, string, end); while (fonsTextIterNext(ctx->fs, &iter, &q)) { positions[npos].str = iter.str; - positions[npos].x = px * invscale; - px = iter.x; + positions[npos].x = iter.x * invscale; + positions[npos].minx = q.x0 * invscale; + positions[npos].maxx = q.x1 * invscale; npos++; if (npos >= maxPositions) break; diff --git a/src/nanovg.h b/src/nanovg.h index 7dd0b15..fb85b01 100644 --- a/src/nanovg.h +++ b/src/nanovg.h @@ -89,7 +89,8 @@ enum NVGalpha { struct NVGglyphPosition { const char* str; // Position of the glyph in the input string. - float x; // The x- coordinate of the position of the glyph . + float x; // The x-coordinate of the logical glyph position. + float minx, maxx; // The bounds of the glyph shape. }; struct NVGtextRow {