From 12319fc2403afd71883da4621c45674336726541 Mon Sep 17 00:00:00 2001 From: __hexmaster111 Date: Tue, 4 Mar 2025 15:13:42 -0600 Subject: [PATCH] Updated measure text to support the defualt raylib font if the user spesfied font failed to load. (#305) --- renderers/raylib/clay_renderer_raylib.c | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/renderers/raylib/clay_renderer_raylib.c b/renderers/raylib/clay_renderer_raylib.c index 19f667d..2b370c6 100644 --- a/renderers/raylib/clay_renderer_raylib.c +++ b/renderers/raylib/clay_renderer_raylib.c @@ -91,8 +91,11 @@ static inline Clay_Dimensions Raylib_MeasureText(Clay_StringSlice text, Clay_Tex float textHeight = config->fontSize; Font* fonts = (Font*)userData; Font fontToUse = fonts[config->fontId]; - // Font failed to load, likely the fonts are in the wrong place relative to the execution dir - if (!fontToUse.glyphs) return textSize; + // Font failed to load, likely the fonts are in the wrong place relative to the execution dir. + // RayLib ships with a default font, so we can continue with that built in one. + if (!fontToUse.glyphs) { + fontToUse = GetFontDefault(); + } float scaleFactor = config->fontSize/(float)fontToUse.baseSize;