diff --git a/stepmania/src/BitmapText.cpp b/stepmania/src/BitmapText.cpp index 457466e595..e364e1212b 100644 --- a/stepmania/src/BitmapText.cpp +++ b/stepmania/src/BitmapText.cpp @@ -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 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; diff --git a/stepmania/src/BitmapText.h b/stepmania/src/BitmapText.h index 516f68b40a..fb4f1156a8 100644 --- a/stepmania/src/BitmapText.h +++ b/stepmania/src/BitmapText.h @@ -87,7 +87,6 @@ protected: vector verts; vector tex; - void AddLine( CString & sAddition, int & iWidthPixels ); void BuildChars(); void DrawChars(); void UpdateBaseZoom(); diff --git a/stepmania/src/Font.cpp b/stepmania/src/Font.cpp index 54769537c5..369e5f561f 100644 --- a/stepmania/src/Font.cpp +++ b/stepmania/src/Font.cpp @@ -19,6 +19,7 @@ const wchar_t Font::DEFAULT_GLYPH = 0xF8FF; FontPage::FontPage() { m_pTexture = NULL; + DrawExtraPixelsLeft = DrawExtraPixelsRight = 0; } void FontPage::Load( FontPageSettings cfg ) @@ -87,6 +88,8 @@ void FontPage::Load( FontPageSettings cfg ) } baseline = cfg.Baseline; height = baseline-cfg.Top; + DrawExtraPixelsLeft = cfg.DrawExtraPixelsLeft; + DrawExtraPixelsRight = cfg.DrawExtraPixelsRight; /* Shift the character up so the top will be rendered at the baseline. */ vshift = (float) -baseline; @@ -188,6 +191,13 @@ int Font::GetLineWidthInSourcePixels( const wstring &szLine ) const for( unsigned i=0; i 0 ) + { + /* Add overdraw. */ + LineWidth += GetGlyph(szLine[0]).fp->DrawExtraPixelsLeft; + LineWidth += GetGlyph(szLine[szLine.size()-1]).fp->DrawExtraPixelsRight; + } + return LineWidth; } diff --git a/stepmania/src/Font.h b/stepmania/src/Font.h index 874e61dbb7..236526c275 100644 --- a/stepmania/src/Font.h +++ b/stepmania/src/Font.h @@ -89,6 +89,9 @@ public: float vshift; int GetCenter() const { return height/2; } + /* Remember these only for GetLineWidthInSourcePixels. */ + int DrawExtraPixelsLeft, DrawExtraPixelsRight; + private: void SetExtraPixels(int DrawExtraPixelsLeft, int DrawExtraPixelsRight); void SetTextureCoords(const vector &widths, int AdvanceExtraPixels);