Skip to content

Add support for inline RGB everywhere#1064

Open
alppp wants to merge 17 commits intoGTNewHorizons:masterfrom
alppp:master
Open

Add support for inline RGB everywhere#1064
alppp wants to merge 17 commits intoGTNewHorizons:masterfrom
alppp:master

Conversation

@alppp
Copy link

@alppp alppp commented Oct 21, 2025

This PR adds support for custom RGB colors and fun text effects to Angelica's font rendering system. (Thanks to the person/s worked on smoothfont alternative)

This supports actual RGB + Legacy

Format Example Meaning
&x &l, &r Control codes (0-9, a-f, g-h, k-o, r).
&RRGGBB &FF8800 Inline RGB colour.
<RRGGBB> <00FFAA> Tag-based RGB colour.
</RRGGBB> </00FFAA> Close the tag and restore the previous colour.

Examples

&00FF00Green chunk&r back to white &FF8800&lBold orange headline&r plain body <00AAFF>Sky blue <FF00FF>magenta highlight</FF00FF> back to blue</00AAFF>

&gRainbow text cycles through all hues!&r Back to normal.

&hUpside-down text (Dinnerbone effect)&r Normal text again.

&g&lBold rainbow text&r or &h&oItalic upside-down&r - effects can be combined!
2025-10-21T23:01:02,147885380+03:00

Also i tried my best highlight UI in text to make creating colored text easier.
Works on names of items, and possibly tooltips and basically everywhere as long person is using angelica.
2025-10-21T15:25:04,060993488+03:00
2025-10-21T15:23:51,306295797+03:00

@Nikolay-Sitnikov
Copy link

Does the ampersand represent the paragraph symbol, or are we just letting every player color their text however they want? (Not a bad thing by any means, it opens up creativity.)

@Dream-Master Dream-Master requested a review from a team October 22, 2025 08:57
@KAMKEEL
Copy link

KAMKEEL commented Oct 22, 2025

Does the ampersand represent the paragraph symbol, or are we just letting every player color their text however they want? (Not a bad thing by any means, it opens up creativity.)

The ampersand symbol is typically used by Plugins in Bukkit to allow players to type the section symbol in chat without some fancy mod to color code text, etc. It is essentially an alternative to it.

@KAMKEEL
Copy link

KAMKEEL commented Oct 23, 2025

I found an issue. I think it has to do with the String Length system and it the way it calculates. I have a mod known a Book Editor that allows you to click and edit books within the Book GUI system. https://github.com/KAMKEEL/BookEditor

If I test this mod on master and type within a Book all the cursor placements are correct, which means the String Lengths are calculating correctly.

However, once I move to this branch the cursor length becomes completely unreasonable.

@KAMKEEL
Copy link

KAMKEEL commented Oct 23, 2025

Also I think it would be extremely beneficial to have the String Length, Strip Colorcodes, etc all in GTNHLib so other mods can support this color coding in their systems. It's what I plan to do.

@mitchej123
Copy link
Collaborator

Yah. I'd love to see nhlib have these functions and strip the extra out of Angelica or another compatible mod isn't available.

@alppp
Copy link
Author

alppp commented Oct 23, 2025

I found an issue. I think it has to do with the String Length system and it the way it calculates. I have a mod known a Book Editor that allows you to click and edit books within the Book GUI system. https://github.com/KAMKEEL/BookEditor

If I test this mod on master and type within a Book all the cursor placements are correct, which means the String Lengths are calculating correctly.

However, once I move to this branch the cursor length becomes completely unreasonable.

Almost all mods need a patch, including BQ (in theory last pr shouldn't) and other areas that does NOT use similar techniques for rendering/displaying text. It did work for chat and sign and names, and probably it will work on other areas that are more "vanilla" (like tooltips). Outside this becomes a nightmare to fix every singular mod(as long it does not use cursed system is not needed). The system works only if you don't change mouse (to preview, however as long "text" is done doesn't matter).

Also I think it would be extremely beneficial to have the String Length, Strip Colorcodes, etc all in GTNHLib so other mods can support this color coding in their systems. It's what I plan to do.

Whole reason i did on angelica because is much easier for me to handle everything related to fonts without becoming a mess, especially rendering part. (also that smoothfont PR helped quite bit). I haven't check the GTNHLib repo to see if is similar with this.
I don't know what's is the portion of playerbase that doesn't play with angelica. And probably on angelica benefits more than just gtnhlib(cuz it can exist outside).

Better idea would be JSON TextComponents where has multiple pro's but that would be in hodgepodge where i have to strip quite bit of things(and would be far too more complicate) and compat with angelica for rendering part.

P.S GTNHLib also deal's with rendering?

@DeathFuel
Copy link
Contributor

Take a look at GTNewHorizons/BetterQuesting#172 and how it interacts with the PRs it links, specifically the GTNHLib PR. If you implement your string width calculations there, you should be fine, because it overwrites vanilla methods and simultaneously acts as a central point for unruly mods (like BQ) to be redirected to. I'm not sure if it's a perfect system, but it's worked well so far

@KAMKEEL
Copy link

KAMKEEL commented Oct 23, 2025

Also, the formatting for color codes are not in par with legacy. Essentially, ever new color code should reset the formatting state to that new color. For example

&a&lTest is a Lime Bold Test.

It should not be &l&aTest

Therefore: &a&lTest &9Word -- Word is a BLUE text with no formatting alterations, no bold.

@KAMKEEL
Copy link

KAMKEEL commented Oct 24, 2025

I found an issue. I think it has to do with the String Length system and it the way it calculates. I have a mod known a Book Editor that allows you to click and edit books within the Book GUI system. https://github.com/KAMKEEL/BookEditor
If I test this mod on master and type within a Book all the cursor placements are correct, which means the String Lengths are calculating correctly.
However, once I move to this branch the cursor length becomes completely unreasonable.

Almost all mods need a patch, including BQ (in theory last pr shouldn't) and other areas that does NOT use similar techniques for rendering/displaying text. It did work for chat and sign and names, and probably it will work on other areas that are more "vanilla" (like tooltips). Outside this becomes a nightmare to fix every singular mod(as long it does not use cursed system is not needed). The system works only if you don't change mouse (to preview, however as long "text" is done doesn't matter).

Also I think it would be extremely beneficial to have the String Length, Strip Colorcodes, etc all in GTNHLib so other mods can support this color coding in their systems. It's what I plan to do.

Whole reason i did on angelica because is much easier for me to handle everything related to fonts without becoming a mess, especially rendering part. (also that smoothfont PR helped quite bit). I haven't check the GTNHLib repo to see if is similar with this. I don't know what's is the portion of playerbase that doesn't play with angelica. And probably on angelica benefits more than just gtnhlib(cuz it can exist outside).

Better idea would be JSON TextComponents where has multiple pro's but that would be in hodgepodge where i have to strip quite bit of things(and would be far too more complicate) and compat with angelica for rendering part.

P.S GTNHLib also deal's with rendering?

Angelica requires GTNHLib to run. It's a dependency of the mod and utilized by a lot of other maintained 1.7.10 mods.

@KAMKEEL
Copy link

KAMKEEL commented Oct 24, 2025

Alright, I made a ton of fixes on my branch https://github.com/KAMKEEL/Angelica/tree/color-code

It now calculates string lengths correctly. Therefore, the book editor works as intended which means its producing a Vanilla-Like output to help bring compatibility to other mods without the need of a library so far. They will require everyone to have Angelica to see the RBG values. But, for now this is a great solution. Still working on other fixes.

@alppp
Copy link
Author

alppp commented Oct 24, 2025

Alright, I made a ton of fixes on my branch https://github.com/KAMKEEL/Angelica/tree/color-code

It now calculates string lengths correctly. Therefore, the book editor works as intended which means its producing a Vanilla-Like output to help bring compatibility to other mods without the need of a library so far. They will require everyone to have Angelica to see the RBG values. But, for now this is a great solution. Still working on other fixes.

The better solution would be to create extra font metadata that can store font colors like other text editors that deal with this, probably is a good idea but to apply in practice might take quite bit of time. And 70+% for sure not compatible with proxies.

Also, the formatting for color codes are not in par with legacy. Essentially, ever new color code should reset the formatting state to that new color. For example

&a&lTest is a Lime Bold Test.

It should not be &l&aTest

Therefore: &a&lTest &9Word -- Word is a BLUE text with no formatting alterations, no bold.

Well i tried to introduce modern formatting and legacy hybrid. Tried to consume least amount of time to do it and i wanted to be intuitive and not waste any characters. I like at-least not waste any extra space that is precious in other places. But if others thinks is not good idea then feel free to true legacy.
P.S You can contact me on discord alpderps. If kamkeel pr is rejected(or accepted, then please close this) i will move to do a hybrid hodgepodge + gtnhlib to achieve slightly better option.

@OvermindDL1
Copy link

OvermindDL1 commented Oct 24, 2025

There is a specific area in Unicode specifically for application specific data like color codes yes, and yes they should work with proxies because if they didn't then they'd be violating Unicode, and thus would break on random other things anyway.

KAMKEEL and others added 4 commits October 25, 2025 14:50
…e Port for Hodgepodge, etc

Added Better Utility Handling within ForattedTextMetrics and ColorCodeUtils. Created an optional Strip Color Codes method for Universal Usage.
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.

6 participants