mirror of
https://github.com/raysan5/raylib.git
synced 2025-10-03 16:36:26 +00:00
Lazy loading of default font for image loading (no InitWindow)
This commit is contained in:
@@ -219,7 +219,7 @@
|
|||||||
//----------------------------------------------------------------------------------
|
//----------------------------------------------------------------------------------
|
||||||
// Other Modules Functions Declaration (required by text)
|
// Other Modules Functions Declaration (required by text)
|
||||||
//----------------------------------------------------------------------------------
|
//----------------------------------------------------------------------------------
|
||||||
// ...
|
extern void LoadFontDefault(void); // [Module: text] Loads default font, required by ImageDrawText()
|
||||||
|
|
||||||
//----------------------------------------------------------------------------------
|
//----------------------------------------------------------------------------------
|
||||||
// Module specific Functions Declaration
|
// Module specific Functions Declaration
|
||||||
@@ -3152,6 +3152,9 @@ void ImageDraw(Image *dst, Image src, Rectangle srcRec, Rectangle dstRec, Color
|
|||||||
void ImageDrawText(Image *dst, const char *text, int posX, int posY, int fontSize, Color color)
|
void ImageDrawText(Image *dst, const char *text, int posX, int posY, int fontSize, Color color)
|
||||||
{
|
{
|
||||||
#if defined(SUPPORT_MODULE_RTEXT)
|
#if defined(SUPPORT_MODULE_RTEXT)
|
||||||
|
// Make sure default font is loaded to be used on image text drawing
|
||||||
|
if (GetFontDefault().texture.id == 0) LoadFontDefault();
|
||||||
|
|
||||||
Vector2 position = { (float)posX, (float)posY };
|
Vector2 position = { (float)posX, (float)posY };
|
||||||
// NOTE: For default font, spacing is set to desired font size / default font size (10)
|
// NOTE: For default font, spacing is set to desired font size / default font size (10)
|
||||||
ImageDrawTextEx(dst, GetFontDefault(), text, position, (float)fontSize, (float)fontSize/10, color); // WARNING: Module required: rtext
|
ImageDrawTextEx(dst, GetFontDefault(), text, position, (float)fontSize, (float)fontSize/10, color); // WARNING: Module required: rtext
|
||||||
|
Reference in New Issue
Block a user