revert weird wrapping hack. I can't make sense of it, and it's causing
infinite loops. Implement overdraw handling correctly.
This commit is contained in:
@@ -387,8 +387,6 @@ void BitmapText::SetText( const CString& _sText, const CString& _sAlternateText,
|
||||
CString sCurLine;
|
||||
int iCurLineWidth = 0;
|
||||
|
||||
/* Note that GetLineWidthInSourcePixels does not include horizontal overdraw
|
||||
* right now (eg. italic fonts), so it's possible to go slightly over. */
|
||||
for( unsigned i=0; i<asWords.size(); i++ )
|
||||
{
|
||||
const CString &sWord = asWords[i];
|
||||
@@ -410,77 +408,19 @@ void BitmapText::SetText( const CString& _sText, const CString& _sAlternateText,
|
||||
}
|
||||
else
|
||||
{
|
||||
AddLine( sCurLine, iCurLineWidth );
|
||||
if ( sCurLine.length() != 0 )
|
||||
{
|
||||
sCurLine += " " + sWord;
|
||||
iCurLineWidth += iWidthWord;
|
||||
}
|
||||
else
|
||||
{
|
||||
sCurLine = sWord;
|
||||
iCurLineWidth = iWidthWord;
|
||||
}
|
||||
m_wTextLines.push_back( CStringToWstring(sCurLine) );
|
||||
sCurLine = sWord;
|
||||
iCurLineWidth = iWidthWord;
|
||||
}
|
||||
}
|
||||
int LastWidth = iCurLineWidth;
|
||||
while ( sCurLine.length() > 0 )
|
||||
{
|
||||
AddLine( sCurLine, iCurLineWidth );
|
||||
if ( LastWidth < iCurLineWidth )
|
||||
break; //Something's wrong (infinite loop)
|
||||
else
|
||||
LastWidth = iCurLineWidth;
|
||||
}
|
||||
m_wTextLines.push_back( CStringToWstring(sCurLine) );
|
||||
}
|
||||
}
|
||||
|
||||
//XXX: YUCK! This is horrible... but basically, in order to make sure we are
|
||||
//in sync with all of the color changes, we have to add bogus spaces at the end
|
||||
//of all lines.
|
||||
|
||||
BuildChars();
|
||||
UpdateBaseZoom();
|
||||
}
|
||||
|
||||
/* This will get called only if the sAddition is already somewhat
|
||||
broken down into lines. This is in place only to handle single
|
||||
words that are too wide for the line. */
|
||||
void BitmapText::AddLine( CString &sAddition, int & iWidthPixels )
|
||||
{
|
||||
if ( ( iWidthPixels < m_iWrapWidthPixels ) || ( sAddition.length() == 0 ) )
|
||||
{
|
||||
m_wTextLines.push_back( CStringToWstring( sAddition ) );
|
||||
sAddition = "";
|
||||
iWidthPixels = 0;
|
||||
}
|
||||
else
|
||||
{
|
||||
CString sCurrentLine;
|
||||
int iCurrentLineWidth = 0;
|
||||
for ( unsigned i = 0; i < sAddition.length(); i++ )
|
||||
{
|
||||
CString sCurrentChar = sAddition.substr( i, 1 );
|
||||
int iCurrentCharWidth = m_pFont->GetLineWidthInSourcePixels( CStringToWstring( sCurrentChar ) );
|
||||
|
||||
if ( iCurrentLineWidth + iCurrentCharWidth > m_iWrapWidthPixels )
|
||||
{
|
||||
if ( sCurrentLine.length() != 0 )
|
||||
m_wTextLines.push_back( CStringToWstring( sCurrentLine ) );
|
||||
sCurrentLine = sCurrentChar;
|
||||
iCurrentLineWidth = iCurrentCharWidth;
|
||||
}
|
||||
else
|
||||
{
|
||||
sCurrentLine += sCurrentChar;
|
||||
iCurrentLineWidth += iCurrentCharWidth;
|
||||
}
|
||||
}
|
||||
sAddition = sCurrentLine;
|
||||
iWidthPixels = iCurrentLineWidth;
|
||||
}
|
||||
}
|
||||
|
||||
void BitmapText::SetMaxWidth( float fMaxWidth )
|
||||
{
|
||||
m_fMaxWidth = fMaxWidth;
|
||||
|
||||
Reference in New Issue
Block a user