diff --git a/src/k3font.c b/src/k3font.c index 854e0d3..119a04d 100644 --- a/src/k3font.c +++ b/src/k3font.c @@ -153,13 +153,15 @@ void k3FontDraw(struct k3Font *this, float xStart, float yStart, float sz, const break; } - lineLength++; - struct k3FontGlyph *g = k3FontGetGlyph(this, cp2); if(g) { if(lineWidth + g->width * this->lineScale * sz > wall) { break; } + } + + lineLength++; + if(g) { lineWidth += g->xadvance * this->lineScale * sz; } } @@ -189,7 +191,7 @@ void k3FontDraw(struct k3Font *this, float xStart, float yStart, float sz, const size_t texH = this->texH; k3BatchAdd(tex, - (struct k3RectF) {(float) g->x / texW, (float) g->y / texH, (float) g->width / texW, (float) g->height / texH}, + (struct k3RectF) {(float) (g->x + 0.5) / texW, (float) (g->y + 0.5) / texH, (float) (g->width - 1) / texW, (float) (g->height - 1) / texH}, (struct k3RectF) { x + g->xoffset * this->lineScale * sz, y + ((-g->height - g->yoffset) * this->lineScale + 1) * sz,