Fix font rendering for color and formatting codes (#1017)

* Fix "Colormatic" splash text rendering as single color

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

* Use per-vertex coloring in a single batch

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

* Fix font rendering for color and formatting codes

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

---------

Signed-off-by: Ayush Thoren <ayushthoren@gmail.com>
This commit is contained in:
Ayush Thoren
2026-03-21 21:33:35 -07:00
committed by GitHub
parent 250accd40b
commit be7e2ca91d
2 changed files with 160 additions and 145 deletions

View File

@@ -38,7 +38,7 @@ private:
std::map<int, int> m_charMap;
public:
Font(Options *options, const wstring& name, Textures* textures, bool enforceUnicode, ResourceLocation *textureLocation, int cols, int rows, int charWidth, int charHeight, unsigned short charMap[] = nullptr);
Font(Options *options, const wstring& name, Textures* textures, bool enforceUnicode, ResourceLocation *textureLocation, int cols, int rows, int charWidth, int charHeight, unsigned short charMap[] = nullptr);
#ifndef _XBOX
// 4J Stu - This dtor clashes with one in xui! We never delete these anyway so take it out for now. Can go back when we have got rid of XUI
~Font();
@@ -48,6 +48,8 @@ public:
private:
void renderCharacter(wchar_t c); // 4J added
void addCharacterQuad(wchar_t c);
void addSolidQuad(float x0, float y0, float x1, float y1);
void emitCharacterGeometry(wchar_t c);
void renderStyleLine(float x0, float y0, float x1, float y1); // solid line for underline/strikethrough
public:
@@ -65,7 +67,7 @@ public:
private:
wstring reorderBidi(const wstring &str);
void draw(const wstring &str, bool dropShadow);
void draw(const wstring &str, bool dropShadow, int baseColor);
void draw(const wstring& str, int x, int y, int color, bool dropShadow);
void drawLiteral(const wstring& str, int x, int y, int color); // no § parsing
int MapCharacter(wchar_t c); // 4J added