Skip to content

Fix font rendering for color and formatting codes #1017

Open
ayushthoren wants to merge 3 commits intosmartcmd:mainfrom
ayushthoren:font-color-fix
Open

Fix font rendering for color and formatting codes #1017
ayushthoren wants to merge 3 commits intosmartcmd:mainfrom
ayushthoren:font-color-fix

Conversation

@ayushthoren
Copy link
Contributor

@ayushthoren ayushthoren commented Mar 9, 2026

Edits: This PR was originally made to fix just the "Colormatic" splash text appearance, but has since fixed more general issues with the font renderer.

Description

Fixes issues with font color and formatting when using the tesselator-based text renderer.

Changes

Previous Behavior

Text using formatting codes such as color (§c, §a) and styles (§n, §m, etc.) could render incorrectly.

  • Colored segments would end up overwriting previous color formatting for parts of the string in the same batch.
  • Underline and strikethrough lines sometimes appeared with the wrong color or did not match the text color.

Notably, one consequence of this is that the Colormaitc splash (§1C§2o§3l§4o§5r§6m§7a§8t§9i§ac) rendered in one flat color instead of showing per-segment colors.

Root Cause

Font rendering mixed two rendering paths:

  • Glyphs were emitted through the tesselator batch.
  • Underline and strikethrough lines were drawn using a helper that relied on GL color state.
    Because the style lines were not part of the tesselator batch, they did not use the same vertex color as the text and could render incorrectly.

New Behavior

Formatted text now renders consistently, with underline and strikethrough lines matching the color of the surrounding text and all formatted glyphs rendering correctly in the same batch.

Fix Implementation

In Minecraft.Client/Font.cpp, style line rendering was moved into the tesselator path.

  • Underline and strikethrough quads are now emitted directly during glyph rendering.
  • A small helper (addSolidQuad) was added to emit these quads inside the active tesselator batch.
  • Glyph vertex emission was moved into emitCharacterGeometry to remove duplicated geometry code.

This ensures previous glyphs keep their original color and new ones use the updated color.

AI Use Disclosure

I used AI as a tool to track down the possible root causes of the rendering issues, then confirmed them and implemented the fixes myself.

Related Issues

  • Fixes Discord Thread 1480350614977384550

How it looked before:

Test splash
Screenshot 2026-03-09 192732
Colormatic splash
image

How it looks after:

Test splash
Screenshot 2026-03-09 195611
Colormatic splash
image

Signed-off-by: Ayush Thoren <ayushthoren@gmail.com>
@TorutheRedFox
Copy link

wouldn't it be efficient to keep rendering in the same batch but use vertex colors to apply the color instead?

Signed-off-by: Ayush Thoren <ayushthoren@gmail.com>
@ayushthoren
Copy link
Contributor Author

Yep, hopefully these changes are more optimized!

New implementation:
Keep the batch fully intact, just apply colors per-vertex (instead of to the whole thing like the original, unfixed code did).

Signed-off-by: Ayush Thoren <ayushthoren@gmail.com>
@ayushthoren ayushthoren changed the title Fix "Colormatic" splash text rendering as single color Fix font rendering for color and formatting codes Mar 10, 2026
@ayushthoren
Copy link
Contributor Author

Well, I went down a rabbit hole and found that there were some more glaring issues with the font renderer involving some of the other formatting options. Details have been added in the edited PR description.

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