The problem
The ] character was rendered incorrectly in the client. A small extra pixel/artifact appeared near the bottom-right corner of the character, making it look like there was a comma or dot after it.
For example:
[CH1]ˏ
[15]ˏ
At first, this looked like a chat formatting problem, especially because I was working on a custom shout chat system containing an empire flag, channel and level information.
The important observation was this:
could initially look correct, but after another character or even a space was rendered after it:]
the unwanted pixel/artifact appeared.],
],A
],1
The problem was especially visible with strings such as:
[CH1]
[15]
[66]
Things that did NOT fix it
Several possible causes were tested first.
1. Disabling text outline
For example:
Code:
pChatLine->Instance.SetOutline(FALSE);
pChatLine->InstanceChannel.SetOutline(FALSE);
pChatLine->InstanceLevel.SetOutline(FALSE);So the outline renderer was not the cause.
2. Changing the font
The default font configuration was also tested.
For example:
Code:
UI_DEF_FONT Tahoma:12
UI_DEF_FONT_LARGE Tahoma:14
UI_DEF_FONT_SMALL Tahoma:9Therefore, the problem was not simply a broken ] glyph in Tahoma.
3. Changing glyph UV coordinates
The normal glyph rendering code in GrpTextInstance.cpp uses:
Code:
akVertex[0].u = pCurCharInfo->left;
akVertex[0].v = pCurCharInfo->top;
akVertex[1].u = pCurCharInfo->left;
akVertex[1].v = pCurCharInfo->bottom;
akVertex[2].u = pCurCharInfo->right;
akVertex[2].v = pCurCharInfo->top;
akVertex[3].u = pCurCharInfo->right;
akVertex[3].v = pCurCharInfo->bottom;Code:
const float uInset = 0.5f / textureWidth;
const float vInset = 0.5f / textureHeight;The actual source of the problem
The problem was eventually traced to:
EterLib/GrpFontTexture.cpp
inside:
Code:
CGraphicFontTexture::UpdateCharacterInfomation(...)The relevant call is:
Code:
TextOutW(hDC, m_x, m_y, &keyValue, 1);This could leave unwanted pixel data in the glyph area. With certain characters, particularly the narrow ] glyph, the leftover data became very noticeable and looked like a comma/dot attached to the bottom-right of the character.
The fix
In EterLib/GrpFontTexture.cpp search:
Code:
CGraphicFontTexture::UpdateCharacterInfomation(...)
TextOutW(hDC, m_x, m_y, &keyValue, 1);Replace:
Code:
TextOutW(hDC, m_x, m_y, &keyValue, 1);So the important fix is:
After recompiling the client, the unwanted dot/comma-like artifact after ] disappeared.
Custom shout chat notes
While debugging this, I was also implementing a custom shout layout:
Instead of trying to align everything using spaces in the server-generated string, the channel and level were separated into their own CGraphicTextInstance objects:[Empire Flag] [CH1] [LEVEL] PlayerName: Message
Code:
InstanceChannel
InstanceLevel
InstanceOne important detail when extracting [LEVEL] is preserving the brackets for rendering.
To display:
Code:
[15]But to obtain only the numeric value for level-based coloring:
So:
Code:
levelText = [15]
numberText = 15The same principle applies to [CH1] if the brackets need to remain visible.
Final result
The final shout layout works correctly:
The channel and level can have independent colors and positions, and the strange artifact after ] is gone.[Empire Flag] [CH1] [66] PlayerName: Message
TL;DR
If your Metin2 client renders something that looks like an extra . or , after ], especially after another character is added, check:
EterLib/GrpFontTexture.cpp
Code:
CGraphicFontTexture::UpdateCharacterInfomation()That was the actual fix in my case.
Hope this saves somebody else a few hours of debugging.

la acest mesaj și conținutul se va afișa automat.



