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

[rtext] BMFont loading, support RGB and RGBA image formats #4730

Closed
wants to merge 6 commits into from

Conversation

GithubPrankster
Copy link
Contributor

@GithubPrankster GithubPrankster commented Jan 26, 2025

With this PR, if the BMFont file points to images that aren't grayscale, they will now load and be converted. This allows the images to be, for example, .qoi ones which are solely RGBA.

I'm curious if failing the format check should throw a log warning, let me know and I'll add that. EDIT: Subsequently added a log warning.

src/rtext.c Fixed Show fixed Hide fixed
@raysan5
Copy link
Owner

raysan5 commented Jan 27, 2025

@GithubPrankster I'm seeing multiple points of improvement on this PR. In case of GRAYSCALE only, it can be converted to GRAYSCALE+ALPHA but in case of an image with already provided Alpha, it can use the full RGB color.

Also, the changes do not follow raylib coding conventions: parenthesis on conditions, brackets alignment, operations symbols spacing, not enum types...

@raysan5 raysan5 changed the title RGB and RGBA image support for BMFont loading [rtext] BMFont loading, support RGB and RGBA image formats Jan 27, 2025
@GithubPrankster
Copy link
Contributor Author

but in case of an image with already provided Alpha, it can use the full RGB color.

So it should just be a copy of the image?

// Convert image to GRAYSCALE + ALPHA, using the mask as the alpha channel

Image imFont = {
.data = RL_CALLOC(imFonts[i].width * imFonts[i].height, 2),

Check failure

Code scanning / CodeQL

Uncontrolled allocation size High

This allocation size is derived from
user input (string read by fread)
and could allocate arbitrary amounts of memory.
@raysan5
Copy link
Owner

raysan5 commented Jan 28, 2025

@GithubPrankster I'm afraid I'm not merging this change, the approach of picking up R channel in any case (using stride) is not the desired behaviour.

@raysan5 raysan5 closed this Jan 28, 2025
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