X-Git-Url: https://git.gag.com/?a=blobdiff_plain;f=src%2Fdraw%2Fao_text.c;h=8f5307ab99e474a76292dc2fe45378f49bbf8b5b;hb=bf7d2aaccd41837dd2e032023107616266e22a6d;hp=be19238838300547236be659398f14c6e1db4547;hpb=f9e2f41feac8ccd4e02020cf672366b194d2d60d;p=fw%2Faltos diff --git a/src/draw/ao_text.c b/src/draw/ao_text.c index be192388..8f5307ab 100644 --- a/src/draw/ao_text.c +++ b/src/draw/ao_text.c @@ -12,31 +12,32 @@ * General Public License for more details. */ -#include "ao_draw.h" -#include "ao_draw_int.h" +#include +#include #include "ao_font.h" #include #include -void -ao_text(const struct ao_bitmap *dst, +extern uint32_t ao_glyph_temp[]; + +static struct ao_bitmap src_bitmap = { + .base = ao_glyph_temp, +}; + +int16_t +ao_text(struct ao_bitmap *dst, const struct ao_font *font, int16_t x, int16_t y, - char *string, + const char *string, uint32_t fill, uint8_t rop) { - int glyph_stride = (font->max_width + 31) / 32; - uint32_t src[glyph_stride * font->max_height]; + int16_t glyph_stride = ao_stride(font->max_width); char c; int h; - int8_t x_off, y_off, advance; - int byte_width; - - struct ao_bitmap src_bitmap = { - .base = src, - }; + int16_t x_off = 0, y_off = 0, advance = 0; + int16_t byte_width = 0; rop = (rop & 3) | 0x4; @@ -45,11 +46,12 @@ ao_text(const struct ao_bitmap *dst, if (!font->metrics) { src_bitmap.width = font->max_width; - src_bitmap.height = font->max_width; + src_bitmap.height = font->max_height; src_bitmap.stride = glyph_stride; x_off = 0; y_off = font->ascent; advance = font->max_width; + byte_width = ao_stride_bytes(font->max_width); } while ((c = *string++)) { const uint8_t *bytes = &font->bytes[font->pos[(uint8_t) c]]; @@ -58,15 +60,15 @@ ao_text(const struct ao_bitmap *dst, const struct ao_glyph_metrics *m = &font->metrics[(uint8_t) c]; src_bitmap.width = m->width; src_bitmap.height = m->height; - src_bitmap.stride = (m->width + 31) / 32; + src_bitmap.stride = ao_stride(m->width); x_off = m->x_off; y_off = m->y_off; advance = m->advance; - byte_width = ((src_bitmap.width + 7) / 8); + byte_width = ao_stride_bytes(m->width); } for (h = 0; h < src_bitmap.height; h++) - memcpy(&src[h * src_bitmap.stride], &bytes[h * byte_width], byte_width); + memcpy(&ao_glyph_temp[h * src_bitmap.stride], &bytes[h * byte_width], (size_t) byte_width); ao_copy(dst, x + x_off, y - y_off, src_bitmap.width, src_bitmap.height, @@ -74,4 +76,5 @@ ao_text(const struct ao_bitmap *dst, 0, 0, rop); x += advance; } + return x; }