Fix for unsafe call of MeasureTextEx in GetTextWidth (#204)

This commit is contained in:
gulrak 2022-05-21 20:05:23 +02:00 committed by GitHub
parent 7b2e7a107b
commit 694e770351
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -3740,8 +3740,8 @@ static int GetTextWidth(const char *text)
}
}
}
size = MeasureTextEx(guiFont, text + textIconOffset, (float)GuiGetStyle(DEFAULT, TEXT_SIZE), (float)GuiGetStyle(DEFAULT, TEXT_SPACING));
float fontSize = (float)GuiGetStyle(DEFAULT, TEXT_SIZE); // ensures guiFont is set
size = MeasureTextEx(guiFont, text + textIconOffset, fontSize, (float)GuiGetStyle(DEFAULT, TEXT_SPACING));
if (textIconOffset > 0) size.x += (RAYGUI_ICON_SIZE - 4); //ICON_TEXT_PADDING
}