Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix negative X output value in MeasureTextEx #4448

Merged
merged 1 commit into from
Oct 29, 2024

Conversation

mpv-enjoyer
Copy link
Contributor

MeasureTextEx used to output negative X for empty strings with non-zero spacing, for example

#include <raylib.h>
#include <stdio.h>

int main()
{
	InitWindow(400, 600, "Raylib window");
	printf("%f \n", MeasureTextEx(GetFontDefault(), "", 10.0f, 0).x); // 0
	printf("%f \n", MeasureTextEx(GetFontDefault(), "", 10.0f, 1).x); // -1
	printf("%f \n", MeasureTextEx(GetFontDefault(), "", 10.0f, 2).x); // -2
	printf("%f \n", MeasureTextEx(GetFontDefault(), "", 10.0f, 15).x); // -15
	CloseWindow();
}

@raysan5 raysan5 merged commit de7ab83 into raysan5:master Oct 29, 2024
@raysan5
Copy link
Owner

raysan5 commented Oct 29, 2024

@mpv-enjoyer thanks for finding this issue, I think it's better to move the check to beginning to avoid all processing in case of a string starting with '\0'. I'm changing it.

psxdev pushed a commit to raylib4Consoles/raylib that referenced this pull request Nov 18, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants