Skip to content

Commit

Permalink
Merge pull request #642 from mulle-nat/typofix
Browse files Browse the repository at this point in the history
small typo fix and documentation fix
  • Loading branch information
vinjn authored Aug 26, 2023
2 parents d146ff5 + f008848 commit f93799c
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 @@ -2543,7 +2543,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 @@ -2556,11 +2556,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 @@ -2861,7 +2861,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 @@ -2893,11 +2893,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 f93799c

Please sign in to comment.