Add fallback strings, so we can fall back on translit text if

we're missing characters (eg. someone distributing a song
using kanji that not all people have) instead of showing the
default glyph
This commit is contained in:
Glenn Maynard
2003-02-12 19:34:53 +00:00
parent f4bfdda745
commit caee0fc111
2 changed files with 21 additions and 7 deletions
+18 -5
View File
@@ -129,6 +129,7 @@ void BitmapText::BuildChars()
/* calculate line lengths and widths */
m_iWidestLineWidth = 0;
m_iLineWidths.clear();
for( unsigned l=0; l<m_szTextLines.size(); l++ ) // for each line
{
m_iLineWidths.push_back(m_pFont->GetLineWidthInSourcePixels( m_szTextLines[l] ));
@@ -218,11 +219,25 @@ void BitmapText::DrawChars()
}
}
/* sText is UTF-8. */
void BitmapText::SetText( CString sText )
/* sText is UTF-8. If PREFSMAN->UseAlternateText is enabled, and not all
* of the characters in sText are available in the font, sAlternateText
* will be used instead. This is normally enabled; the option exists
* as a troubleshooting option (so should only be shown in a debug options
* menu) for the case that a string isn't being displayed, to find out
* which character is causing problems. If there are unavailable characters
* in sAlternateText, too, just use sText.
* XXX: implement PREFSMAN->UseAlternateText */
void BitmapText::SetText( CString sText, CString sAlternateText )
{
ASSERT( m_pFont );
if(sAlternateText.size())
{
if(!m_pFont->FontCompleteForString(CStringToWstring(sText)) &&
m_pFont->FontCompleteForString(CStringToWstring(sAlternateText)))
sText = sAlternateText;
}
if(m_szText == sText)
return;
@@ -230,9 +245,7 @@ void BitmapText::SetText( CString sText )
/* Break the string into lines. */
m_szTextLines.clear();
m_iLineWidths.clear();
split(CStringToWstring(sText), L"\n", m_szTextLines, false);
split(CStringToWstring(m_szText), L"\n", m_szTextLines, false);
BuildChars();
}
+3 -2
View File
@@ -26,7 +26,7 @@ public:
bool LoadFromFont( CString sFontName );
bool LoadFromNumbers( CString sTexturePath ) { return LoadFromTextureAndChars(sTexturePath,"0123456789%. :x"); };
bool LoadFromTextureAndChars( CString sTexturePath, CString sChars );
void SetText( CString sText );
void SetText( CString sText, CString sAlternateText = "" );
int GetWidestLineWidthInSourcePixels() { return m_iWidestLineWidth; };
void CropToWidth( int iWidthInSourcePixels );
@@ -39,8 +39,9 @@ public:
void SetHorizAlign( HorizAlign ha );
void SetVertAlign( VertAlign va );
CString GetText() const { return m_szText; }
public:
CString m_sFontFilePath;
Font* m_pFont;
protected: