Browse Source

Added some TODOs, no return value for textbox

shared-context
Mikko Mononen 11 years ago
parent
commit
7a282bd934
2 changed files with 11 additions and 5 deletions
  1. +10
    -4
      src/nanovg.c
  2. +1
    -1
      src/nanovg.h

+ 10
- 4
src/nanovg.c View File

@@ -2002,7 +2002,7 @@ float nvgText(struct NVGcontext* ctx, float x, float y, const char* string, cons
return iter.x;
}

float nvgTextBox(struct NVGcontext* ctx, float x, float y, float width, const char* string, const char* end)
void nvgTextBox(struct NVGcontext* ctx, float x, float y, float width, const char* string, const char* end)
{
struct NVGstate* state = nvg__getState(ctx);
struct NVGtextRow rows[2];
@@ -2012,7 +2012,7 @@ float nvgTextBox(struct NVGcontext* ctx, float x, float y, float width, const ch
int valign = state->textAlign & (NVG_ALIGN_TOP | NVG_ALIGN_MIDDLE | NVG_ALIGN_BOTTOM | NVG_ALIGN_BASELINE);
float lineh = 0;

if (state->fontId == FONS_INVALID) return x;
if (state->fontId == FONS_INVALID) return;

nvgTextMetrics(ctx, NULL, NULL, &lineh);

@@ -2033,8 +2033,6 @@ float nvgTextBox(struct NVGcontext* ctx, float x, float y, float width, const ch
}

state->textAlign = oldAlign;

return 0; // TODO
}

int nvgTextGlyphPositions(struct NVGcontext* ctx, const char* string, const char* end, float x, float y, struct NVGglyphPosition* positions, int maxPositions)
@@ -2053,6 +2051,8 @@ int nvgTextGlyphPositions(struct NVGcontext* ctx, const char* string, const char
if (string == end)
return 0;

// TODO: should use scaled text to better match with rendering.

fonsSetSize(ctx->fs, state->fontSize);
fonsSetSpacing(ctx->fs, state->letterSpacing);
fonsSetBlur(ctx->fs, state->fontBlur);
@@ -2104,6 +2104,8 @@ int nvgTextBreakLines(struct NVGcontext* ctx, const char* string, const char* en

if (string == end) return 0;

// TODO: should use scaled text to better match with rendering.

fonsSetSize(ctx->fs, state->fontSize);
fonsSetSpacing(ctx->fs, state->letterSpacing);
fonsSetBlur(ctx->fs, state->fontBlur);
@@ -2242,6 +2244,8 @@ float nvgTextBounds(struct NVGcontext* ctx, const char* string, const char* end,

if (state->fontId == FONS_INVALID) return 0;

// TODO: should use scaled text to better match with rendering.

fonsSetSize(ctx->fs, state->fontSize);
fonsSetSpacing(ctx->fs, state->letterSpacing);
fonsSetBlur(ctx->fs, state->fontBlur);
@@ -2257,6 +2261,8 @@ void nvgTextMetrics(struct NVGcontext* ctx, float* ascender, float* descender, f

if (state->fontId == FONS_INVALID) return;

// TODO: should use scaled text to better match with rendering.

fonsSetSize(ctx->fs, state->fontSize);
fonsSetSpacing(ctx->fs, state->letterSpacing);
fonsSetBlur(ctx->fs, state->fontBlur);


+ 1
- 1
src/nanovg.h View File

@@ -427,7 +427,7 @@ float nvgText(struct NVGcontext* ctx, float x, float y, const char* string, cons
// Draws multi-line text string at specified location wrapped at the specified width. If end is specified only the sub-string up to the end is drawn.
// White space is stripped at the beginning of the rows, the text is split at word boundaries or when new-line characters are encountered.
// Words longer than the max width are slit at nearest character (i.e. no hyphenation).
float nvgTextBox(struct NVGcontext* ctx, float x, float y, float width, const char* string, const char* end);
void nvgTextBox(struct NVGcontext* ctx, float x, float y, float width, const char* string, const char* end);

// Measures the specified text string. Parameter bounds should be a pointer to float[4] if
// the bounding box of the text should be returned. Returns the width of the measured text.


Loading…
Cancel
Save