Skip to content

Commit

Permalink
small typo fix and documentation fix
Browse files Browse the repository at this point in the history
  • Loading branch information
mulle-nat committed Aug 3, 2022
1 parent 397f330 commit f008848
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 9 deletions.
16 changes: 8 additions & 8 deletions src/nanovg.c
Original file line number Diff line number Diff line change
Expand Up @@ -2540,7 +2540,7 @@ void nvgTextBox(NVGcontext* ctx, float x, float y, float breakRowWidth, const ch
NVGtextRow rows[2];
int nrows = 0, i;
int oldAlign = state->textAlign;
int haling = state->textAlign & (NVG_ALIGN_LEFT | NVG_ALIGN_CENTER | NVG_ALIGN_RIGHT);
int halign = state->textAlign & (NVG_ALIGN_LEFT | NVG_ALIGN_CENTER | NVG_ALIGN_RIGHT);
int valign = state->textAlign & (NVG_ALIGN_TOP | NVG_ALIGN_MIDDLE | NVG_ALIGN_BOTTOM | NVG_ALIGN_BASELINE);
float lineh = 0;

Expand All @@ -2553,11 +2553,11 @@ void nvgTextBox(NVGcontext* ctx, float x, float y, float breakRowWidth, const ch
while ((nrows = nvgTextBreakLines(ctx, string, end, breakRowWidth, rows, 2))) {
for (i = 0; i < nrows; i++) {
NVGtextRow* row = &rows[i];
if (haling & NVG_ALIGN_LEFT)
if (halign & NVG_ALIGN_LEFT)
nvgText(ctx, x, y, row->start, row->end);
else if (haling & NVG_ALIGN_CENTER)
else if (halign & NVG_ALIGN_CENTER)
nvgText(ctx, x + breakRowWidth*0.5f - row->width*0.5f, y, row->start, row->end);
else if (haling & NVG_ALIGN_RIGHT)
else if (halign & NVG_ALIGN_RIGHT)
nvgText(ctx, x + breakRowWidth - row->width, y, row->start, row->end);
y += lineh * state->lineHeight;
}
Expand Down Expand Up @@ -2858,7 +2858,7 @@ void nvgTextBoxBounds(NVGcontext* ctx, float x, float y, float breakRowWidth, co
float invscale = 1.0f / scale;
int nrows = 0, i;
int oldAlign = state->textAlign;
int haling = state->textAlign & (NVG_ALIGN_LEFT | NVG_ALIGN_CENTER | NVG_ALIGN_RIGHT);
int halign = state->textAlign & (NVG_ALIGN_LEFT | NVG_ALIGN_CENTER | NVG_ALIGN_RIGHT);
int valign = state->textAlign & (NVG_ALIGN_TOP | NVG_ALIGN_MIDDLE | NVG_ALIGN_BOTTOM | NVG_ALIGN_BASELINE);
float lineh = 0, rminy = 0, rmaxy = 0;
float minx, miny, maxx, maxy;
Expand Down Expand Up @@ -2890,11 +2890,11 @@ void nvgTextBoxBounds(NVGcontext* ctx, float x, float y, float breakRowWidth, co
NVGtextRow* row = &rows[i];
float rminx, rmaxx, dx = 0;
// Horizontal bounds
if (haling & NVG_ALIGN_LEFT)
if (halign & NVG_ALIGN_LEFT)
dx = 0;
else if (haling & NVG_ALIGN_CENTER)
else if (halign & NVG_ALIGN_CENTER)
dx = breakRowWidth*0.5f - row->width*0.5f;
else if (haling & NVG_ALIGN_RIGHT)
else if (halign & NVG_ALIGN_RIGHT)
dx = breakRowWidth - row->width;
rminx = x + row->minx + dx;
rmaxx = x + row->maxx + dx;
Expand Down
2 changes: 1 addition & 1 deletion src/nanovg.h
Original file line number Diff line number Diff line change
Expand Up @@ -537,7 +537,7 @@ void nvgStroke(NVGcontext* ctx);
// const char* txt = "Text me up.";
// nvgTextBounds(vg, x,y, txt, NULL, bounds);
// nvgBeginPath(vg);
// nvgRoundedRect(vg, bounds[0],bounds[1], bounds[2]-bounds[0], bounds[3]-bounds[1]);
// nvgRect(vg, bounds[0],bounds[1], bounds[2]-bounds[0], bounds[3]-bounds[1]);
// nvgFill(vg);
//
// Note: currently only solid color fill is supported for text.
Expand Down

0 comments on commit f008848

Please sign in to comment.