Added support for linebreaks in font_blit (effects love.graphics.print)

This commit is contained in:
rxi
2016-09-23 19:32:00 +01:00
parent 1940897a4a
commit dcb909b7ba

View File

@@ -131,13 +131,17 @@ void font_blit(font_t *self, pixel_t *buf, int bufw, int bufh,
image_flip = 0; image_flip = 0;
while (*p) { while (*p) {
stbtt_bakedchar *g = &self->glyphs[(int) (*p & 127)]; if (*p == '\n') {
int w = g->x1 - g->x0; x = dx;
int h = g->y1 - g->y0; y += self->height;
image_blit( } else {
&self->image, buf, bufw, bufh, stbtt_bakedchar *g = &self->glyphs[(int) (*p & 127)];
x + g->xoff, y + g->yoff, g->x0, g->y0, w, h); int w = g->x1 - g->x0;
x += g->xadvance; int h = g->y1 - g->y0;
image_blit(&self->image, buf, bufw, bufh,
x + g->xoff, y + g->yoff, g->x0, g->y0, w, h);
x += g->xadvance;
}
p++; p++;
} }