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;
|
CString sCurLine;
|
||||||
int iCurLineWidth = 0;
|
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++ )
|
for( unsigned i=0; i<asWords.size(); i++ )
|
||||||
{
|
{
|
||||||
const CString &sWord = asWords[i];
|
const CString &sWord = asWords[i];
|
||||||
@@ -410,77 +408,19 @@ void BitmapText::SetText( const CString& _sText, const CString& _sAlternateText,
|
|||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
AddLine( sCurLine, iCurLineWidth );
|
m_wTextLines.push_back( CStringToWstring(sCurLine) );
|
||||||
if ( sCurLine.length() != 0 )
|
|
||||||
{
|
|
||||||
sCurLine += " " + sWord;
|
|
||||||
iCurLineWidth += iWidthWord;
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
sCurLine = sWord;
|
sCurLine = sWord;
|
||||||
iCurLineWidth = iWidthWord;
|
iCurLineWidth = iWidthWord;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
m_wTextLines.push_back( CStringToWstring(sCurLine) );
|
||||||
int LastWidth = iCurLineWidth;
|
|
||||||
while ( sCurLine.length() > 0 )
|
|
||||||
{
|
|
||||||
AddLine( sCurLine, iCurLineWidth );
|
|
||||||
if ( LastWidth < iCurLineWidth )
|
|
||||||
break; //Something's wrong (infinite loop)
|
|
||||||
else
|
|
||||||
LastWidth = iCurLineWidth;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
//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();
|
BuildChars();
|
||||||
UpdateBaseZoom();
|
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 )
|
void BitmapText::SetMaxWidth( float fMaxWidth )
|
||||||
{
|
{
|
||||||
m_fMaxWidth = fMaxWidth;
|
m_fMaxWidth = fMaxWidth;
|
||||||
|
|||||||
@@ -87,7 +87,6 @@ protected:
|
|||||||
vector<RageSpriteVertex> verts;
|
vector<RageSpriteVertex> verts;
|
||||||
vector<RageTexture *> tex;
|
vector<RageTexture *> tex;
|
||||||
|
|
||||||
void AddLine( CString & sAddition, int & iWidthPixels );
|
|
||||||
void BuildChars();
|
void BuildChars();
|
||||||
void DrawChars();
|
void DrawChars();
|
||||||
void UpdateBaseZoom();
|
void UpdateBaseZoom();
|
||||||
|
|||||||
@@ -19,6 +19,7 @@ const wchar_t Font::DEFAULT_GLYPH = 0xF8FF;
|
|||||||
FontPage::FontPage()
|
FontPage::FontPage()
|
||||||
{
|
{
|
||||||
m_pTexture = NULL;
|
m_pTexture = NULL;
|
||||||
|
DrawExtraPixelsLeft = DrawExtraPixelsRight = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
void FontPage::Load( FontPageSettings cfg )
|
void FontPage::Load( FontPageSettings cfg )
|
||||||
@@ -87,6 +88,8 @@ void FontPage::Load( FontPageSettings cfg )
|
|||||||
}
|
}
|
||||||
baseline = cfg.Baseline;
|
baseline = cfg.Baseline;
|
||||||
height = baseline-cfg.Top;
|
height = baseline-cfg.Top;
|
||||||
|
DrawExtraPixelsLeft = cfg.DrawExtraPixelsLeft;
|
||||||
|
DrawExtraPixelsRight = cfg.DrawExtraPixelsRight;
|
||||||
|
|
||||||
/* Shift the character up so the top will be rendered at the baseline. */
|
/* Shift the character up so the top will be rendered at the baseline. */
|
||||||
vshift = (float) -baseline;
|
vshift = (float) -baseline;
|
||||||
@@ -188,6 +191,13 @@ int Font::GetLineWidthInSourcePixels( const wstring &szLine ) const
|
|||||||
for( unsigned i=0; i<szLine.size(); i++ )
|
for( unsigned i=0; i<szLine.size(); i++ )
|
||||||
LineWidth += GetGlyph(szLine[i]).hadvance;
|
LineWidth += GetGlyph(szLine[i]).hadvance;
|
||||||
|
|
||||||
|
if( szLine.size() > 0 )
|
||||||
|
{
|
||||||
|
/* Add overdraw. */
|
||||||
|
LineWidth += GetGlyph(szLine[0]).fp->DrawExtraPixelsLeft;
|
||||||
|
LineWidth += GetGlyph(szLine[szLine.size()-1]).fp->DrawExtraPixelsRight;
|
||||||
|
}
|
||||||
|
|
||||||
return LineWidth;
|
return LineWidth;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -89,6 +89,9 @@ public:
|
|||||||
float vshift;
|
float vshift;
|
||||||
int GetCenter() const { return height/2; }
|
int GetCenter() const { return height/2; }
|
||||||
|
|
||||||
|
/* Remember these only for GetLineWidthInSourcePixels. */
|
||||||
|
int DrawExtraPixelsLeft, DrawExtraPixelsRight;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
void SetExtraPixels(int DrawExtraPixelsLeft, int DrawExtraPixelsRight);
|
void SetExtraPixels(int DrawExtraPixelsLeft, int DrawExtraPixelsRight);
|
||||||
void SetTextureCoords(const vector<int> &widths, int AdvanceExtraPixels);
|
void SetTextureCoords(const vector<int> &widths, int AdvanceExtraPixels);
|
||||||
|
|||||||
Reference in New Issue
Block a user