Updated measure text to support the defualt raylib font if the user spesfied font failed to load.

This commit is contained in:
__hexmaster111 2025-03-04 09:27:43 -06:00 committed by GitHub
parent 02bce89d17
commit ce03ccd6f2
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

View File

@ -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;