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);
75 struct uterm_video_buffer buf;
80 const struct kmscon_font_ops *ops;
81 struct kmscon_font_attr attr;
85 struct kmscon_font_ops {
87 int (*init) (struct kmscon_font *out,
88 const struct kmscon_font_attr *attr);
89 void (*destroy) (struct kmscon_font *font);
90 int (*render) (struct kmscon_font *font, kmscon_symbol_t sym,
91 const struct kmscon_glyph **out);
92 void (*drop) (struct kmscon_font *font,
93 const struct kmscon_glyph *glyph);
96 int kmscon_font_register(const struct kmscon_font_ops *ops);
97 void kmscon_font_unregister(const char *name);
99 int kmscon_font_find(struct kmscon_font **out,
100 const struct kmscon_font_attr *attr,
101 const char *backend);
102 void kmscon_font_ref(struct kmscon_font *font);
103 void kmscon_font_unref(struct kmscon_font *font);
105 int kmscon_font_render(struct kmscon_font *font, kmscon_symbol_t sym,
106 const struct kmscon_glyph **out);
107 void kmscon_font_drop(struct kmscon_font *font,
108 const struct kmscon_glyph *glyph);
110 /* modularized backends */
112 int kmscon_font_8x16_load(void);
113 void kmscon_font_8x16_unload(void);
115 #endif /* KMSCON_TEXT_H */