6 /// default (built-in) font id
7 #define FNT_DEFAULT (0)
8 /// Value returned on errors
11 /** Initializes the font subsystem */
14 /** Terminates the font subsystem */
18 * @param buffer The memory buffer containing the font
19 * @param bufferSize Size of the buffer
20 * @param takeover Set to nonzero
21 * @return font slot id (negative value means error happened) */
22 int fntLoad(void* buffer
, int bufferSize
, int takeover
);
24 /** Loads a font from a file path
25 * @param path The path to the font file
26 * @return font slot id (negative value means error happened) */
27 int fntLoadFile(char* path
);
29 /** Replaces the given font slot with the defined font */
30 void fntReplace(int id
, void* buffer
, int bufferSize
, int takeover
, int asDefault
);
32 /** Reloads the default font into the given font slot */
33 void fntSetDefault(int id
);
35 /** Releases a font slot */
36 void fntRelease(int id
);
38 /** Sets a new aspect ratio
39 * @note Invalidates the whole glyph cache for all fonts! */
40 void fntSetAspectRatio(float aw
, float ah
);
43 * @return the new x position after drawing */
44 int fntRenderString(int font
, int x
, int y
, short aligned
, const unsigned char* string
, u64 colour
);
46 /** Renders a text with specified window dimensions */
47 void fntRenderText(int font
, int sx
, int sy
, short aligned
, size_t width
, size_t height
, const unsigned char* string
, u64 colour
);
49 /** replaces spaces with newlines so that the text fits into the specified width.
50 * @note A destrutive operation - modifies the given string!
52 void fntFitString(int font
, unsigned char *string
, size_t width
);
54 /** Calculates the width of the given text string
55 * We can't use the height for alignment, as the horizontal center would depends of the contained text itself */
56 int fntCalcDimensions(int font
, const unsigned char* str
);