diff options
| author | Ray <[email protected]> | 2023-03-22 20:11:36 +0100 |
|---|---|---|
| committer | Ray <[email protected]> | 2023-03-22 20:11:36 +0100 |
| commit | 6287f68c0bb172ac70bfbe30617d9480ab4eab1f (patch) | |
| tree | 41873abb3eac9378dcefab6ac8f702fc7afaeaba /src | |
| parent | 0925851f896fd82ef91804cdf2429d3a75e72aeb (diff) | |
| download | raylib-6287f68c0bb172ac70bfbe30617d9480ab4eab1f.tar.gz raylib-6287f68c0bb172ac70bfbe30617d9480ab4eab1f.zip | |
Lazy loading of default font for image loading (no InitWindow)
Diffstat (limited to 'src')
| -rw-r--r-- | src/rtextures.c | 5 |
1 files changed, 4 insertions, 1 deletions
diff --git a/src/rtextures.c b/src/rtextures.c index b5f9998a..fb63f2ff 100644 --- a/src/rtextures.c +++ b/src/rtextures.c @@ -219,7 +219,7 @@ //---------------------------------------------------------------------------------- // Other Modules Functions Declaration (required by text) //---------------------------------------------------------------------------------- -// ... +extern void LoadFontDefault(void); // [Module: text] Loads default font, required by ImageDrawText() //---------------------------------------------------------------------------------- // 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) { #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 }; // 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 |
