From b00ab118c6a86713042ebc172a7108682a268a03 Mon Sep 17 00:00:00 2001 From: raysan5 Date: Tue, 2 Jun 2020 23:07:11 +0200 Subject: [PATCH] [examples] text_font_sdf - Corrected bug --- examples/text/text_font_sdf.c | 2 +- src/text.c | 6 ++++++ 2 files changed, 7 insertions(+), 1 deletion(-) diff --git a/examples/text/text_font_sdf.c b/examples/text/text_font_sdf.c index 067bb820..2cbe5150 100644 --- a/examples/text/text_font_sdf.c +++ b/examples/text/text_font_sdf.c @@ -48,7 +48,7 @@ int main(void) fontSDF.baseSize = 16; fontSDF.charsCount = 95; // Parameters > font size: 16, no chars array provided (0), chars count: 0 (defaults to 95) - fontSDF.chars = LoadFontData("resources/AnonymousPro-Bold.ttf", 16, 0, 0, FONT_SDF); + fontSDF.chars = LoadFontData("resources/anonymous_pro_bold.ttf", 16, 0, 0, FONT_SDF); // Parameters > chars count: 95, font size: 16, chars padding in image: 0 px, pack method: 1 (Skyline algorythm) atlas = GenImageFontAtlas(fontSDF.chars, &fontSDF.recs, 95, 16, 0, 1); fontSDF.texture = LoadTextureFromImage(atlas); diff --git a/src/text.c b/src/text.c index 3c2c9924..51fee3eb 100644 --- a/src/text.c +++ b/src/text.c @@ -622,6 +622,12 @@ Image GenImageFontAtlas(const CharInfo *chars, Rectangle **charRecs, int charsCo { Image atlas = { 0 }; + if (chars == NULL) + { + TraceLog(LOG_WARNING, "FONT: Provided chars info not valid, returning empty image atlas"); + return atlas; + } + *charRecs = NULL; // In case no chars count provided we suppose default of 95