comparison src/font.h @ 10:c91c3272101b

core: implement fonts, closes #2444
author David Demelier <markand@malikania.fr>
date Tue, 07 Jan 2020 20:28:35 +0100
parents
children fc71221b7bee
comparison
equal deleted inserted replaced
9:66f318fd97a0 10:c91c3272101b
1 /*
2 * font.h -- basic font management
3 *
4 * Copyright (c) 2020 David Demelier <markand@malikania.fr>
5 *
6 * Permission to use, copy, modify, and/or distribute this software for any
7 * purpose with or without fee is hereby granted, provided that the above
8 * copyright notice and this permission notice appear in all copies.
9 *
10 * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
11 * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
12 * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
13 * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
14 * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
15 * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
16 * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
17 */
18
19 #ifndef MOLKO_FONT_H
20 #define MOLKO_FONT_H
21
22 /**
23 * \file font.h
24 * \brief Basic font management.
25 */
26
27 #include <stddef.h>
28
29 struct font;
30 struct texture;
31
32 /**
33 * Open font from path file.
34 *
35 * \pre path != NULL
36 * \param path the path to the font
37 * \param size the desired size
38 * \return the font or NULL on error
39 */
40 struct font *
41 font_openf(const char *path, unsigned size);
42
43 /**
44 * Open font from memory buffer.
45 *
46 * \pre buffer != NULL
47 * \param buffer the memory buffer
48 * \param buflen the memory buffer length
49 * \param size the desired size
50 * \warning The buffer must remain valid until font is closed
51 * \return the font or NULL on error
52 */
53 struct font *
54 font_openb(const void *buffer, size_t buflen, unsigned size);
55
56 /**
57 * Render a text.
58 *
59 * \pre font != NULL
60 * \pre text != NULL
61 * \param font the font handle
62 * \param text the text in UTF-8
63 * \param color the color
64 */
65 struct texture *
66 font_render(struct font *font, const char *text, uint32_t color);
67
68 /**
69 * Close the font.
70 *
71 * \pre font != NULL
72 * \param font the font handle
73 */
74 void
75 font_close(struct font *font);
76
77 #endif /* !MOLKO_FONT_H */