altosui: Add config and pyro tabs to graph widget
[fw/altos] / src / draw / ao_text.c
index cb1bc5abce72380b61af9026d7c15f6940370749..8f5307ab99e474a76292dc2fe45378f49bbf8b5b 100644 (file)
  * General Public License for more details.
  */
 
-#include "ao_draw.h"
-#include "ao_draw_int.h"
+#include <ao_draw.h>
+#include <ao_draw_int.h>
 #include "ao_font.h"
 #include <string.h>
 #include <stdio.h>
 
-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)
 {
        int16_t         glyph_stride = ao_stride(font->max_width);
-       uint32_t        src[glyph_stride * font->max_height];
        char            c;
        int             h;
        int16_t         x_off = 0, y_off = 0, advance = 0;
        int16_t         byte_width = 0;
 
-       struct ao_bitmap        src_bitmap = {
-               .base = src,
-       };
-
        rop = (rop & 3) | 0x4;
 
        if ((fill&1) == 0)
@@ -67,7 +68,7 @@ ao_text(const struct ao_bitmap        *dst,
                }
 
                for (h = 0; h < src_bitmap.height; h++)
-                       memcpy(&src[h * src_bitmap.stride], &bytes[h * byte_width], (size_t) 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,
@@ -75,4 +76,5 @@ ao_text(const struct ao_bitmap        *dst,
                        0, 0, rop);
                x += advance;
        }
+       return x;
 }