summaryrefslogtreecommitdiffhomepage
path: root/src
diff options
context:
space:
mode:
authorRay <[email protected]>2021-05-03 19:05:43 +0200
committerRay <[email protected]>2021-05-03 19:05:43 +0200
commit2015828fc68b1af6adf3846580fa912a7726dcf8 (patch)
treeaea20f8402d8138ee19d6c9e08a34138ab013fa3 /src
parent4c1af4cc90913559e629c85470308b9e1a68f9a3 (diff)
downloadraylib-2015828fc68b1af6adf3846580fa912a7726dcf8.tar.gz
raylib-2015828fc68b1af6adf3846580fa912a7726dcf8.zip
Security check in case of not valid font
Diffstat (limited to 'src')
-rw-r--r--src/text.c6
1 files changed, 4 insertions, 2 deletions
diff --git a/src/text.c b/src/text.c
index 3a49963a..3e821fe8 100644
--- a/src/text.c
+++ b/src/text.c
@@ -848,12 +848,14 @@ void DrawText(const char *text, int posX, int posY, int fontSize, Color color)
// NOTE: chars spacing is NOT proportional to fontSize
void DrawTextEx(Font font, const char *text, Vector2 position, float fontSize, float spacing, Color tint)
{
- int length = TextLength(text); // Total length in bytes of the text, scanned by codepoints in loop
+ if (font.texture.id == 0) font = GetFontDefault(); // Security check in case of not valid font
+
+ int length = TextLength(text); // Total length in bytes of the text, scanned by codepoints in loop
int textOffsetY = 0; // Offset between lines (on line break '\n')
float textOffsetX = 0.0f; // Offset X to next character to draw
- float scaleFactor = fontSize/font.baseSize; // Character quad scaling factor
+ float scaleFactor = fontSize/font.baseSize; // Character quad scaling factor
for (int i = 0; i < length;)
{