@@ -115,7 +115,7 @@ void CGraphics::DrawString ( int uiLeft, int uiTop, int uiRight, int uiBottom, u
115
115
std::wstring strText = MbUTF8ToUTF16 (szText);
116
116
117
117
if ( bOutline )
118
- DrawStringBlurred ( rect, ulColor & 0xFF000000 , strText.c_str (), ulFormat, pDXFont );
118
+ DrawStringOutline ( rect, ulColor, strText.c_str (), ulFormat, pDXFont );
119
119
pDXFont->DrawTextW ( m_pDXSprite, strText.c_str (), -1 , &rect, ulFormat, ulColor );
120
120
EndDrawBatch ();
121
121
}
@@ -134,23 +134,43 @@ void CGraphics::DrawString ( int iX, int iY, unsigned long dwColor, float fScale
134
134
}
135
135
136
136
// Slow
137
- void CGraphics::DrawStringBlurred (const RECT& rect, unsigned long ulColor, const wchar_t * szText, unsigned long ulFormat, LPD3DXFONT pDXFont)
138
- {
139
- // Blur definition
140
- const float E = 0 ;
141
- const float D = 0 .33f ;
142
- const float C = 0 .66f ;
143
- const float B = 1 ;
144
- const float A = 0 ;
145
- static const float kernelData[] = {
146
- E, D, D, D, E,
147
- D, C, B, C, D,
148
- D, B, A, B, D,
149
- D, C, B, C, D,
150
- E, D, D, D, E };
137
+ void CGraphics::DrawStringOutline (const RECT& rect, unsigned long ulColor, const wchar_t * szText, unsigned long ulFormat, LPD3DXFONT pDXFont)
138
+ {
151
139
const uint uiKernelSizeX = 5 ;
152
140
const uint uiKernelSizeY = 5 ;
153
- const float * pKernel = kernelData;
141
+ const float * pKernel;
142
+
143
+ // Select outline style
144
+ int iRed = (ulColor & 0x00FF0000 ) >> 16 ;
145
+ int iGreen = (ulColor & 0x0000FF00 ) >> 8 ;
146
+ int iBlue = (ulColor & 0x000000FF ) >> 0 ;
147
+ float fBrightness = (iRed * 0 .299f + iGreen * 0 .587f + iBlue * 0 .114f );
148
+ if (fBrightness > 64 )
149
+ {
150
+ // Use black outline with thicker border
151
+ ulColor = ulColor & 0xFF000000 ;
152
+ const float F = 0 , E = 0 .16f , D = 0 .33f , C = 0 .66f , B = 1 , A = 0 ;
153
+ static const float kernelData[] = {
154
+ F, E, D, E, F,
155
+ E, C, B, C, E,
156
+ D, B, A, B, D,
157
+ E, C, B, C, E,
158
+ F, E, D, E, F };
159
+ pKernel = kernelData;
160
+ }
161
+ else
162
+ {
163
+ // Use white outline with thinner border
164
+ ulColor = ulColor | 0x00FFFFFF ;
165
+ const float F = 0 , E = 0 , D = 0 .25f , C = 0 .5f , B = 1 , A = 0 ;
166
+ static const float kernelData[] = {
167
+ F, E, D, E, F,
168
+ E, C, B, C, E,
169
+ D, B, A, B, D,
170
+ E, C, B, C, E,
171
+ F, E, D, E, F };
172
+ pKernel = kernelData;
173
+ }
154
174
155
175
// Apply definition
156
176
int iInputAlpha = (ulColor & 0xFF000000 ) >> 24 ;
0 commit comments