1DTK_LOAD_FONT(3) Draw Toolkit manual DTK_LOAD_FONT(3)
2
3
4
6 dtk_load_font - Load an font
7
9 #include <drawtk.h>
10
11 dtk_hfont dtk_load_font(const char *fontname);
12 void dtk_destroy_font(dtk_hfont font);
13
15 dtk_load_font() loads the font specified by fontname argument. This
16 should be the path of a file whose file format can be any of the file
17 format supported by the freetype library (TrueType and Type 1 among
18 many others) or a font description pattern understood by fontconfig
19 (like "Times new roman:bold"). dtk_load_font() will first interpret
20 fontname as a font filename and then, if this fail interpret as a font
21 pattern and load the closest font available on the system.
22
23 Upon creation, the font data is then tracked by an internal resource
24 manager so that the next call using the same fontname argument will
25 return the same font handle, thus sparing the resources of the system.
26
27 There is no need for a valid window to create successfully a font, i.e.
28 font loading is completely decoupled from the creation of others
29 resources and can even be created in one thread to be used in another
30 one.
31
32 dtk_destroy_font() frees the resource referenced by font. If the font
33 is used several times, i.e. several call to dtk_load_font() with the
34 same file path, it decreases the number of uses by one.
35
36 Calling dtk_destroy_texture() on each created font is currently not
37 mandatory since all font remaining fonts are destroyed when the last
38 window is closed. However, if no window can be closed (for example, no
39 window has been created), dtk_destroy_font() should be called on each
40 created font to avoid any memory leak.
41
43 In case of success, the dtk_load_font() returns the handle to the
44 loaded font. In case of failure, NULL is returned.
45
46 dtk_destroy_texture() does not return any value.
47
49 dtk_load_font() and dtk_destroy_texture() are thread-safe.
50
52 dtk_create_string(3) fc-list(1) FcPatternFormat(3)
53
54
55
56
57
58EPFL 2010 DTK_LOAD_FONT(3)