Fix font boundary

This commit is contained in:
Mid 2025-09-19 23:10:25 +03:00
parent 9bc549546f
commit 1ee7d6c26e

View File

@ -153,13 +153,15 @@ void k3FontDraw(struct k3Font *this, float xStart, float yStart, float sz, const
break; break;
} }
lineLength++;
struct k3FontGlyph *g = k3FontGetGlyph(this, cp2); struct k3FontGlyph *g = k3FontGetGlyph(this, cp2);
if(g) { if(g) {
if(lineWidth + g->width * this->lineScale * sz > wall) { if(lineWidth + g->width * this->lineScale * sz > wall) {
break; break;
} }
}
lineLength++;
if(g) {
lineWidth += g->xadvance * this->lineScale * sz; 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; size_t texH = this->texH;
k3BatchAdd(tex, 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) { (struct k3RectF) {
x + g->xoffset * this->lineScale * sz, x + g->xoffset * this->lineScale * sz,
y + ((-g->height - g->yoffset) * this->lineScale + 1) * sz, y + ((-g->height - g->yoffset) * this->lineScale + 1) * sz,