Skip to content

Commit

Permalink
made anti-aliasing for text rendering possible
Browse files Browse the repository at this point in the history
I'm still experimenting, if it makes sense, to activate it, though.
  • Loading branch information
sven-n committed Oct 27, 2023
1 parent d70dbb9 commit 9819f4f
Showing 1 changed file with 12 additions and 0 deletions.
12 changes: 12 additions & 0 deletions Source Main 5.2/source/UIControls.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2701,10 +2701,22 @@ void CUIRenderTextOriginal::WriteText(int iOffset, int iWidth, int iHeight)
{
*reinterpret_cast<unsigned int*>(pBitmapFont->Buffer + DstIndex) = m_dwTextColor;
}
else if (*(m_pFontBuffer + SrcIndex) != 0) // we hit a semi transparent pixel, so anti aliasing hit here
{
// The alpha channel is the highest 8 bits.
DWORD alpha = *(m_pFontBuffer + SrcIndex);
alpha += *(m_pFontBuffer + SrcIndex + 1);
alpha += *(m_pFontBuffer + SrcIndex + 2);
alpha /= 3;
alpha <<= 24;
alpha |= 0x00FFFFFF;
*reinterpret_cast<unsigned int*>(pBitmapFont->Buffer + DstIndex) = m_dwTextColor & alpha;
}
else // it's a black pixel, so there is no text
{
*reinterpret_cast<unsigned int*>(pBitmapFont->Buffer + DstIndex) = 0; // Transparent
}

SrcIndex += 3; // RBG
DstIndex += 4; // RGBA
}
Expand Down

0 comments on commit 9819f4f

Please sign in to comment.