Browse Source

Removed scaling from nvgTextBounds and nvgVertMetrics and commented the behavior

shared-context
Mikko Mononen 11 years ago
parent
commit
ecb0a9c394
2 changed files with 8 additions and 8 deletions
  1. +6
    -8
      src/nanovg.c
  2. +2
    -0
      src/nanovg.h

+ 6
- 8
src/nanovg.c View File

@@ -1664,13 +1664,12 @@ float nvgText(struct NVGcontext* ctx, float x, float y, const char* string, cons
float nvgTextBounds(struct NVGcontext* ctx, const char* string, const char* end, float* bounds)
{
struct NVGstate* state = nvg__getState(ctx);
float scale = 1.0f; // nvg__getFontScale(state);

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

fonsSetSize(ctx->fs, state->fontSize*scale);
fonsSetSpacing(ctx->fs, state->letterSpacing*scale);
fonsSetBlur(ctx->fs, state->fontBlur*scale);
fonsSetSize(ctx->fs, state->fontSize);
fonsSetSpacing(ctx->fs, state->letterSpacing);
fonsSetBlur(ctx->fs, state->fontBlur);
fonsSetAlign(ctx->fs, state->textAlign);
fonsSetFont(ctx->fs, state->fontId);

@@ -1680,13 +1679,12 @@ float nvgTextBounds(struct NVGcontext* ctx, const char* string, const char* end,
void nvgVertMetrics(struct NVGcontext* ctx, float* ascender, float* descender, float* lineh)
{
struct NVGstate* state = nvg__getState(ctx);
float scale = 1.0f; // nvg__getFontScale(state);

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

fonsSetSize(ctx->fs, state->fontSize*scale);
fonsSetSpacing(ctx->fs, state->letterSpacing*scale);
fonsSetBlur(ctx->fs, state->fontBlur*scale);
fonsSetSize(ctx->fs, state->fontSize);
fonsSetSpacing(ctx->fs, state->letterSpacing);
fonsSetBlur(ctx->fs, state->fontBlur);
fonsSetAlign(ctx->fs, state->textAlign);
fonsSetFont(ctx->fs, state->fontId);



+ 2
- 0
src/nanovg.h View File

@@ -356,9 +356,11 @@ float nvgText(struct NVGcontext* ctx, float x, float y, const char* string, cons

// 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.
// Current transform does not affect the measured values.
float nvgTextBounds(struct NVGcontext* ctx, const char* string, const char* end, float* bounds);

// Returns the vertical metrics based on the current text style.
// Current transform does not affect the measured values.
void nvgVertMetrics(struct NVGcontext* ctx, float* ascender, float* descender, float* lineh);




Loading…
Cancel
Save