Mercurial > molko
comparison doc/docs/dev/api/core/font.md @ 253:c4da052c0def
core: goodbye doxygen
author | David Demelier <markand@malikania.fr> |
---|---|
date | Thu, 03 Dec 2020 09:06:52 +0100 |
parents | |
children | 196264679079 |
comparison
equal
deleted
inserted
replaced
252:95c2c4a72410 | 253:c4da052c0def |
---|---|
1 # Module: font | |
2 | |
3 Synopsis | |
4 | |
5 ```c | |
6 #include <core/font.h> | |
7 ``` | |
8 | |
9 Open and use fonts for rendering UTF-8 text. | |
10 | |
11 ## Enums | |
12 | |
13 ### font\_style | |
14 | |
15 Specify the font style to use. | |
16 | |
17 | Enumerator | Description | | |
18 |--------------------------|------------------------------| | |
19 | `FONT_STYLE_ANTIALIASED` | Pretty antialiasing looking. | | |
20 | `FONT_STYLE_NONE` | No antialiasing. | | |
21 | |
22 ## Structs | |
23 | |
24 ### font | |
25 | |
26 A font handle to render text. | |
27 | |
28 | Field | Access | Type | | |
29 |-----------------|--------|-------------------| | |
30 | [style](#style) | (+) | `enum font_style` | | |
31 | |
32 #### style | |
33 | |
34 Font [style](#font_style) to use for the next rendering operations. | |
35 | |
36 ## Functions | |
37 | |
38 ### font\_open | |
39 | |
40 Open and load `font` of the given pixel `size` from file `path`. Returns false | |
41 on errors. | |
42 | |
43 ```c | |
44 bool | |
45 font_open(struct font *font, const char *path, unsigned int size) | |
46 ``` | |
47 | |
48 ### font\_openmem | |
49 | |
50 Open font and load `font` from the const memory buffer pointed by `buffer` and | |
51 of size `buflen` using a pixel size of `size`. Returns false on errors. | |
52 | |
53 !!! note | |
54 The argument `buffer` must stay valid until the font is no longer used. | |
55 | |
56 ```c | |
57 bool | |
58 font_openmem(struct font *font, const void *buffer, size_t buflen, unsigned int size) | |
59 ``` | |
60 | |
61 ### font\_ok | |
62 | |
63 Returns true if the `font` is properly loaded. | |
64 | |
65 ```c | |
66 bool | |
67 font_ok(const struct font *font) | |
68 ``` | |
69 | |
70 ### font\_render | |
71 | |
72 Render the UTF-8 `text` into the texture `tex` using the font pointed by `font`. | |
73 The foreground `color` will be used to draw the text. | |
74 | |
75 Returns false in case of rendering error, in this case `tex` remains | |
76 uninitialized and must not be used. | |
77 | |
78 ```c | |
79 bool | |
80 font_render(struct font *font, struct texture *tex, const char *text, unsigned int color) | |
81 ``` | |
82 | |
83 ### font\_height | |
84 | |
85 Returns the maximum glyph height in pixels present in `font`. | |
86 | |
87 ```c | |
88 unsigned int | |
89 font_height(const struct font *font) | |
90 ``` | |
91 | |
92 ### font\_query | |
93 | |
94 Query the dimensions that the UTF-8 `text` would require with this `font`. Store | |
95 the dimensions into the `w`, `h` pointers which can be both NULL. | |
96 | |
97 Return false in case of error, in this case both `w` and `h` remain | |
98 uninitialized and must not be used. | |
99 | |
100 ```c | |
101 bool | |
102 font_query(const struct font *font, const char *text, unsigned int *w, unsigned int *h) | |
103 ``` | |
104 | |
105 ### font\_finish | |
106 | |
107 Close this `font`. | |
108 | |
109 ```c | |
110 void | |
111 font_finish(struct font *font) | |
112 ``` |