2 * Copyright © 2016 Keith Packard <keithp@keithp.com>
4 * This program is free software; you can redistribute it and/or modify
5 * it under the terms of the GNU General Public License as published by
6 * the Free Software Foundation, either version 2 of the License, or
7 * (at your option) any later version.
9 * This program is distributed in the hope that it will be useful, but
10 * WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
12 * General Public License for more details.
16 #include <ao_draw_int.h>
22 ao_text(struct ao_bitmap *dst,
23 const struct ao_font *font,
30 int16_t glyph_stride = ao_stride(font->max_width);
31 uint32_t src[glyph_stride * font->max_height];
34 int16_t x_off = 0, y_off = 0, advance = 0;
35 int16_t byte_width = 0;
37 struct ao_bitmap src_bitmap = {
41 rop = (rop & 3) | 0x4;
47 src_bitmap.width = font->max_width;
48 src_bitmap.height = font->max_height;
49 src_bitmap.stride = glyph_stride;
52 advance = font->max_width;
53 byte_width = ao_stride_bytes(font->max_width);
55 while ((c = *string++)) {
56 const uint8_t *bytes = &font->bytes[font->pos[(uint8_t) c]];
59 const struct ao_glyph_metrics *m = &font->metrics[(uint8_t) c];
60 src_bitmap.width = m->width;
61 src_bitmap.height = m->height;
62 src_bitmap.stride = ao_stride(m->width);
66 byte_width = ao_stride_bytes(m->width);
69 for (h = 0; h < src_bitmap.height; h++)
70 memcpy(&src[h * src_bitmap.stride], &bytes[h * byte_width], (size_t) byte_width);
73 x + x_off, y - y_off, src_bitmap.width, src_bitmap.height,