68d6c2cfd7f6817b08d7087a6fbd95d4f737f737
[fw/altos] / src / draw / ao_text.c
1 /*
2  * Copyright © 2016 Keith Packard <keithp@keithp.com>
3  *
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.
8  *
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.
13  */
14
15 #include "ao.h"
16 #include "ao_draw.h"
17 #include "ao_font.h"
18
19 void
20 ao_text(char            *string,
21         uint32_t        *dst_line,
22         int16_t         dst_stride,
23         int16_t         dst_x)
24 {
25         char            c;
26         uint32_t        src[GLYPH_HEIGHT];
27
28         while ((c = *string++)) {
29                 uint8_t *bytes = &glyph_bytes[glyph_pos[(uint8_t) c]];
30                 int     h;
31
32                 for (h = 0; h < GLYPH_HEIGHT; h++)
33                         src[h] = bytes[h];
34
35                 ao_blt(src, 1, 0,
36                        dst_line, dst_stride,
37                        dst_x,
38                        GLYPH_WIDTH,
39                        GLYPH_HEIGHT,
40                        AO_AND_INVERTED,
41                        0, 0);
42                 dst_x += GLYPH_WIDTH;
43         }
44 }