2 * kmscon - Font Renderer
4 * Copyright (c) 2012-2013 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.
35 #include "kmscon_module.h"
36 #include "uterm_video.h"
40 struct kmscon_font_attr;
43 struct kmscon_font_ops;
45 #define KMSCON_FONT_MAX_NAME 128
46 #define KMSCON_FONT_DEFAULT_NAME "monospace"
47 #define KMSCON_FONT_DEFAULT_PPI 72
49 struct kmscon_font_attr {
50 char name[KMSCON_FONT_MAX_NAME];
59 void kmscon_font_attr_normalize(struct kmscon_font_attr *attr);
60 bool kmscon_font_attr_match(const struct kmscon_font_attr *a1,
61 const struct kmscon_font_attr *a2);
64 struct uterm_video_buffer buf;
71 struct shl_register_record *record;
72 const struct kmscon_font_ops *ops;
73 struct kmscon_font_attr attr;
74 unsigned int baseline;
78 struct kmscon_font_ops {
80 struct kmscon_module *owner;
81 int (*init) (struct kmscon_font *out,
82 const struct kmscon_font_attr *attr);
83 void (*destroy) (struct kmscon_font *font);
84 int (*render) (struct kmscon_font *font,
85 uint32_t id, const uint32_t *ch, size_t len,
86 const struct kmscon_glyph **out);
87 int (*render_empty) (struct kmscon_font *font,
88 const struct kmscon_glyph **out);
89 int (*render_inval) (struct kmscon_font *font,
90 const struct kmscon_glyph **out);
93 int kmscon_font_register(const struct kmscon_font_ops *ops);
94 void kmscon_font_unregister(const char *name);
96 int kmscon_font_find(struct kmscon_font **out,
97 const struct kmscon_font_attr *attr,
99 void kmscon_font_ref(struct kmscon_font *font);
100 void kmscon_font_unref(struct kmscon_font *font);
102 int kmscon_font_render(struct kmscon_font *font,
103 uint32_t id, const uint32_t *ch, size_t len,
104 const struct kmscon_glyph **out);
105 int kmscon_font_render_empty(struct kmscon_font *font,
106 const struct kmscon_glyph **out);
107 int kmscon_font_render_inval(struct kmscon_font *font,
108 const struct kmscon_glyph **out);
110 /* modularized backends */
112 extern struct kmscon_font_ops kmscon_font_8x16_ops;
113 extern struct kmscon_font_ops kmscon_font_unifont_ops;
114 extern struct kmscon_font_ops kmscon_font_freetype2_ops;
115 extern struct kmscon_font_ops kmscon_font_pango_ops;
117 #endif /* KMSCON_FONT_H */