src/ascension/ui/font.h

changeset 65
9c44c55d327a
parent 48
6e5b5ba2752c
child 66
8297afa1c29c
equal deleted inserted replaced
64:f18dc427f86f 65:9c44c55d327a
50 /** 50 /**
51 * Point size. 51 * Point size.
52 */ 52 */
53 int size; 53 int size;
54 /** 54 /**
55 * TODO: remove from public struct
55 * Pointer to the SDL TTF font structure. 56 * Pointer to the SDL TTF font structure.
56 */ 57 */
57 TTF_Font *ptr; 58 TTF_Font *ptr;
58 } AscFont; 59 } AscFont;
59 60
60 /** 61 /**
61 * Loads a font with the given style and size. 62 * Activates a font with the given style and size.
62 * 63 *
63 * The font is cached and returned faster the next time you call this 64 * The font is cached and activated faster the next time you call this
64 * function with the same arguments. However, when you reach the maximum 65 * function with the same arguments. However, when you reach the maximum
65 * number of fonts, the cache is completely cleared and rebuilt. 66 * number of fonts, the cache is completely cleared and rebuilt.
66 * 67 *
67 * That means in general, that you should not be using too many fonts of 68 * That means in general, that you should not be using too many fonts of
68 * different sizes at the same time, and you should not keep the pointer 69 * different sizes at the same time.
69 * returned by this function too long, because you would risking cache misses.
70 * 70 *
71 * @param style the style 71 * @param style the style
72 * @param size the point size 72 * @param size the point size
73 * @return a pointer to the font structure (do not free)
74 */ 73 */
75 AscFont const *asc_font(enum AscFontStyle style, int size); 74 void asc_font(enum AscFontStyle style, int size);
76
77 /**
78 * Unloads all cached fonts from the context.
79 */
80 void asc_font_cache_clear(void);
81
82 /**
83 * Checks, if the font is still loaded and reloads it, if required.
84 *
85 * There is no need to call this function manually. Every Ascension function
86 * that you pass a font will do that for you and use the returned pointer in
87 * case of a cache miss.
88 *
89 * @param font the font to validate
90 * @return \p font, or a pointer to the new location of the loaded font
91 */
92 AscFont const *asc_font_cache_validate(AscFont const *font);
93 75
94 #endif //ASCENSION_FONT_H 76 #endif //ASCENSION_FONT_H

mercurial