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] Introducing styled texts #4818

Open
wants to merge 3 commits into
base: master
Choose a base branch
from

Conversation

SultansOfCode
Copy link

@SultansOfCode SultansOfCode commented Mar 6, 2025

Hello!

I have added the ability to customize text color and background color with special characters inside the text (pretty much like mIRC does)

You can use the functions DrawTextStyled and DrawTextStyledEx almost as you would use DrawText and DrawTextEx respectively

The changes are: instead of passing the Color, you will pass an array of Colors and the size of this array

Inside the text you can use \003 to set the foreground color, \004 to set the background color, \015 to reset them to their default values (first color in array, if any, as foreground color [or black, if none], and transparent background) and \022 to swap foreground and background colors

Also added MeasureTextStyled and MeasureTextStyledEx to correctly measure them as MeasureText and MeasureTextEx would for plain texts

If any adjustment is needed, either to the code or to the PR, please, let me know

Thank you

@raysan5 raysan5 changed the title Introducing styled texts [rtext] Introducing styled texts Mar 7, 2025
@raysan5
Copy link
Owner

raysan5 commented Mar 11, 2025

@SultansOfCode Thanks for the nice effect! I'm afraid this implementation is too custom to be added to raylib for all users, the styling mechanism should be a user-decision, not imposed by raylib.

Still, it can be directly implemented into a single example intended for users looking for an implementation sample or as a base solution to implement their own.

Please, could you review it to make it self-contained to the example? Also note that examples should follow some guidelines.

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