@@ -218,7 +218,7 @@ class BitmapDC
218
218
CC_BREAK_IF (!pszText || nLen <= 0 );
219
219
220
220
RECT rc = { 0 , 0 , 0 , 0 };
221
- DWORD dwCalcFmt = DT_CALCRECT;
221
+ DWORD dwCalcFmt = DT_CALCRECT | DT_NOPREFIX ;
222
222
if (!enableWrap)
223
223
{
224
224
dwCalcFmt |= DT_SINGLELINE;
@@ -298,12 +298,11 @@ class BitmapDC
298
298
{
299
299
int nRet = 0 ;
300
300
wchar_t * pwszBuffer = nullptr ;
301
- wchar_t * fixedText = nullptr ;
302
301
do
303
302
{
304
303
CC_BREAK_IF (!pszText);
305
304
306
- DWORD dwFmt = DT_WORDBREAK;
305
+ DWORD dwFmt = DT_WORDBREAK | DT_NOPREFIX ;
307
306
if (!enableWrap) {
308
307
dwFmt |= DT_SINGLELINE;
309
308
}
@@ -332,37 +331,7 @@ class BitmapDC
332
331
memset (pwszBuffer, 0 , sizeof (wchar_t )*nBufLen);
333
332
nLen = MultiByteToWideChar (CP_UTF8, 0 , pszText, nLen, pwszBuffer, nBufLen);
334
333
335
- if (strchr (pszText, ' &' ))
336
- {
337
- fixedText = new wchar_t [nLen * 2 + 1 ];
338
- int fixedIndex = 0 ;
339
- for (int index = 0 ; index < nLen; ++index )
340
- {
341
- if (pwszBuffer[index ] == ' &' )
342
- {
343
- fixedText[fixedIndex] = ' &' ;
344
- fixedText[fixedIndex + 1 ] = ' &' ;
345
- fixedIndex += 2 ;
346
- }
347
- else
348
- {
349
- fixedText[fixedIndex] = pwszBuffer[index ];
350
- fixedIndex += 1 ;
351
- }
352
- }
353
- fixedText[fixedIndex] = ' \0 ' ;
354
- nLen = fixedIndex;
355
- }
356
-
357
- SIZE newSize;
358
- if (fixedText)
359
- {
360
- newSize = sizeWithText (fixedText, nLen, dwFmt, fontName, textSize, tSize.cx , tSize.cy , enableWrap, overflow);
361
- }
362
- else
363
- {
364
- newSize = sizeWithText (pwszBuffer, nLen, dwFmt, fontName, textSize, tSize.cx , tSize.cy , enableWrap, overflow);
365
- }
334
+ SIZE newSize = sizeWithText (pwszBuffer, nLen, dwFmt, fontName, textSize, tSize.cx , tSize.cy , enableWrap, overflow);
366
335
367
336
RECT rcText = { 0 };
368
337
// if content width is 0, use text size as content size
@@ -429,20 +398,12 @@ class BitmapDC
429
398
SetTextColor (_DC, RGB (255 , 255 , 255 )); // white color
430
399
431
400
// draw text
432
- if (fixedText)
433
- {
434
- nRet = DrawTextW (_DC, fixedText, nLen, &rcText, dwFmt);
435
- }
436
- else
437
- {
438
- nRet = DrawTextW (_DC, pwszBuffer, nLen, &rcText, dwFmt);
439
- }
401
+ nRet = DrawTextW (_DC, pwszBuffer, nLen, &rcText, dwFmt);
440
402
441
403
SelectObject (_DC, hOldBmp);
442
404
SelectObject (_DC, hOldFont);
443
405
} while (0 );
444
406
CC_SAFE_DELETE_ARRAY (pwszBuffer);
445
- delete[] fixedText;
446
407
447
408
return nRet;
448
409
}
@@ -558,4 +519,4 @@ void Device::vibrate(float duration)
558
519
559
520
NS_CC_END
560
521
561
- #endif // CC_TARGET_PLATFORM == CC_PLATFORM_WIN32
522
+ #endif // CC_TARGET_PLATFORM == CC_PLATFORM_WIN32
0 commit comments