blob: 2caa8accb615d689dae3076d9d82218be9ca260a [file] [log] [blame]
Travis Geiselbrecht99b2d1d2010-05-21 22:57:18 -07001/*
2 * Copyright (c) 2008-2010 Travis Geiselbrecht
3 *
4 * Permission is hereby granted, free of charge, to any person obtaining
5 * a copy of this software and associated documentation files
6 * (the "Software"), to deal in the Software without restriction,
7 * including without limitation the rights to use, copy, modify, merge,
8 * publish, distribute, sublicense, and/or sell copies of the Software,
9 * and to permit persons to whom the Software is furnished to do so,
10 * subject to the following conditions:
11 *
12 * The above copyright notice and this permission notice shall be
13 * included in all copies or substantial portions of the Software.
14 *
15 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
16 * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
17 * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
18 * IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
19 * CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
20 * TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
21 * SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
22 */
23
24/**
25 * @file
26 * @brief Font display
27 *
28 * This file contains functions to render fonts onto the graphics drawing
29 * surface.
30 *
31 * @ingroup graphics
32 */
33
34#include <debug.h>
35#include <lib/gfx.h>
36#include <lib/font.h>
37
38#include "font.h"
39
40/**
41 * @brief Draw one character from the built-in font
42 *
43 * @ingroup graphics
44 */
45void font_draw_char(gfx_surface *surface, unsigned char c, int x, int y, uint32_t color)
46{
47 uint i,j;
48 uint line;
49
50 // draw this char into a buffer
51 for (i = 0; i < FONT_Y; i++) {
52 line = FONT[c * FONT_Y + i];
53 for (j = 0; j < FONT_X; j++) {
54 if (line & 0x1)
55 gfx_putpixel(surface, x + j, y + i, color);
56 line = line >> 1;
57 }
58 }
59 gfx_flush_rows(surface, y, y + FONT_Y);
60}
61
62