2 * kmscon - Text Renderer
4 * Copyright (c) 2012 David Herrmann <dh.herrmann@googlemail.com>
6 * Permission is hereby granted, free of charge, to any person obtaining
7 * a copy of this software and associated documentation files
8 * (the "Software"), to deal in the Software without restriction, including
9 * without limitation the rights to use, copy, modify, merge, publish,
10 * distribute, sublicense, and/or sell copies of the Software, and to
11 * permit persons to whom the Software is furnished to do so, subject to
12 * the following conditions:
14 * The above copyright notice and this permission notice shall be included
15 * in all copies or substantial portions of the Software.
17 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
18 * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
19 * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
20 * IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
21 * CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
22 * TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
23 * SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
28 * The Text-Renderer subsystem provides a simple way to draw text into a
29 * framebuffer. The system is modular and several different backends are
30 * available that can be used.
31 * The system is split into:
32 * - Font renderer: The font renderer allows selecting fonts and rendering
33 * single glyphs into memory-buffers
34 * - Text renderer: The text renderer uses the font renderer to draw a whole
35 * console into a framebuffer.
47 struct kmscon_font_attr;
50 struct kmscon_font_ops;
52 #define KMSCON_FONT_MAX_NAME 128
53 #define KMSCON_FONT_DEFAULT_NAME "monospace"
54 #define KMSCON_FONT_DEFAULT_PPI 72
56 struct kmscon_font_attr {
57 char name[KMSCON_FONT_MAX_NAME];
66 void kmscon_font_attr_normalize(struct kmscon_font_attr *attr);
67 bool kmscon_font_attr_match(const struct kmscon_font_attr *a1,
68 const struct kmscon_font_attr *a2);
73 struct uterm_video_buffer buf;
78 const struct kmscon_font_ops *ops;
79 struct kmscon_font_attr attr;
80 unsigned int baseline;
84 struct kmscon_font_ops {
86 int (*init) (struct kmscon_font *out,
87 const struct kmscon_font_attr *attr);
88 void (*destroy) (struct kmscon_font *font);
89 int (*render) (struct kmscon_font *font, kmscon_symbol_t sym,
90 const struct kmscon_glyph **out);
91 void (*drop) (struct kmscon_font *font,
92 const struct kmscon_glyph *glyph);
95 int kmscon_font_register(const struct kmscon_font_ops *ops);
96 void kmscon_font_unregister(const char *name);
98 int kmscon_font_find(struct kmscon_font **out,
99 const struct kmscon_font_attr *attr,
100 const char *backend);
101 void kmscon_font_ref(struct kmscon_font *font);
102 void kmscon_font_unref(struct kmscon_font *font);
104 int kmscon_font_render(struct kmscon_font *font, kmscon_symbol_t sym,
105 const struct kmscon_glyph **out);
106 void kmscon_font_drop(struct kmscon_font *font,
107 const struct kmscon_glyph *glyph);
109 /* modularized backends */
111 int kmscon_font_8x16_load(void);
112 void kmscon_font_8x16_unload(void);
113 int kmscon_font_pango_load(void);
114 void kmscon_font_pango_unload(void);
116 #endif /* KMSCON_TEXT_H */