]> rtime.felk.cvut.cz Git - l4.git/blob - l4/pkg/libgfxbitmap/include/font.h
Inital import
[l4.git] / l4 / pkg / libgfxbitmap / include / font.h
1 /**
2  * \file
3  * \brief Bitmap font renderer header file.
4  */
5 /*
6  * (c) 2009 Technische Universität Dresden
7  * This file is part of TUD:OS and distributed under the terms of the
8  * GNU Lesser General Public License 2.1.
9  * Please see the COPYING-LGPL-2.1 file for details.
10  */
11 #pragma once
12
13 #include <l4/sys/compiler.h>
14 #include <l4/re/c/video/view.h>
15 #include <l4/libgfxbitmap/bitmap.h>
16
17 /**
18  * \defgroup api_gfxbitmap_font Functions for rendering bitmap fonts to frame buffers
19  * \ingroup api_gfxbitmap
20  */
21
22 /**
23  * \addtogroup api_gfxbitmap_font
24  */
25 /*@{*/
26
27 /**
28  * \brief Constant to use for the default font.
29  */
30 enum { GFXBITMAP_DEFAULT_FONT = 0 };
31
32 /**
33  * \brief Constant for length field.
34  *
35  * Use this if the function should call strlen on the text argument itself.
36  */
37 enum { GFXBITMAP_USE_STRLEN = ~0U };
38
39 EXTERN_C_BEGIN
40
41 /** \brief Font */
42 typedef void *gfxbitmap_font_t;
43
44 /**
45  * \brief Initialize the library.
46  *
47  * This function must be called before any other font function of this
48  * library.
49  */
50 L4_CV int gfxbitmap_font_init(void);
51
52 /**
53  * \brief Get the font width.
54  *
55  * \param font   Font.
56  * \return Font width, 0 if font width could not be retrieved.
57  */
58 L4_CV unsigned
59 gfxbitmap_font_width(gfxbitmap_font_t font);
60
61 /**
62  * \brief Get the font height.
63  *
64  * \param font   Font.
65  * \return Font height, 0 if font height could not be retrieved.
66  */
67 L4_CV unsigned
68 gfxbitmap_font_height(gfxbitmap_font_t font);
69
70 /**
71  * \brief Get bitmap font data for a specific character.
72  *
73  * \param font   Font.
74  * \param c      Character.
75  * \return Pointer to bmap data, NULL on error.
76  */
77 L4_CV void *
78 gfxbitmap_font_data(gfxbitmap_font_t font, unsigned c);
79
80 /**
81  * \brief Render a string to a framebuffer.
82  *
83  * \param fb      Pointer to frame buffer.
84  * \param fbi     Frame buffer info structure.
85  * \param font    Font.
86  * \param text    Text string.
87  * \param len     Length of the text string.
88  * \param x       Horizontal position in the frame buffer.
89  * \param y       Vertical position in the frame buffer.
90  * \param fg      Foreground color.
91  * \param bg      Background color.
92  */
93 L4_CV void
94 gfxbitmap_font_text(void *fb, l4re_video_view_info_t *vi,
95                     gfxbitmap_font_t font, const char *text, unsigned len,
96                     unsigned x, unsigned y,
97                     gfxbitmap_color_pix_t fg, gfxbitmap_color_pix_t bg);
98
99 /**
100  * \brief Render a string to a framebuffer, including scaling.
101  *
102  * \param fb      Pointer to frame buffer.
103  * \param fbi     Frame buffer info structure.
104  * \param font    Font.
105  * \param text    Text string.
106  * \param len     Length of the text string.
107  * \param x       Horizontal position in the frame buffer.
108  * \param y       Vertical position in the frame buffer.
109  * \param fg      Foreground color.
110  * \param bg      Background color.
111  * \param scale_x Horizonal scale factor.
112  * \param scale_y Vertical scale factor.
113  */
114 void
115 gfxbitmap_font_text_scale(void *fb, l4re_video_view_info_t *vi,
116                           gfxbitmap_font_t font, const char *text, unsigned len,
117                           unsigned x, unsigned y,
118                           gfxbitmap_color_pix_t fg, gfxbitmap_color_pix_t bg,
119                           int scale_x, int scale_y);
120 EXTERN_C_END
121 /*@}*/