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:
@@ -129,6 +129,7 @@ void BitmapText::BuildChars()
|
|||||||
/* calculate line lengths and widths */
|
/* calculate line lengths and widths */
|
||||||
m_iWidestLineWidth = 0;
|
m_iWidestLineWidth = 0;
|
||||||
|
|
||||||
|
m_iLineWidths.clear();
|
||||||
for( unsigned l=0; l<m_szTextLines.size(); l++ ) // for each line
|
for( unsigned l=0; l<m_szTextLines.size(); l++ ) // for each line
|
||||||
{
|
{
|
||||||
m_iLineWidths.push_back(m_pFont->GetLineWidthInSourcePixels( m_szTextLines[l] ));
|
m_iLineWidths.push_back(m_pFont->GetLineWidthInSourcePixels( m_szTextLines[l] ));
|
||||||
@@ -218,11 +219,25 @@ void BitmapText::DrawChars()
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/* sText is UTF-8. */
|
/* sText is UTF-8. If PREFSMAN->UseAlternateText is enabled, and not all
|
||||||
void BitmapText::SetText( CString sText )
|
* 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 );
|
ASSERT( m_pFont );
|
||||||
|
|
||||||
|
if(sAlternateText.size())
|
||||||
|
{
|
||||||
|
if(!m_pFont->FontCompleteForString(CStringToWstring(sText)) &&
|
||||||
|
m_pFont->FontCompleteForString(CStringToWstring(sAlternateText)))
|
||||||
|
sText = sAlternateText;
|
||||||
|
}
|
||||||
|
|
||||||
if(m_szText == sText)
|
if(m_szText == sText)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
@@ -230,9 +245,7 @@ void BitmapText::SetText( CString sText )
|
|||||||
|
|
||||||
/* Break the string into lines. */
|
/* Break the string into lines. */
|
||||||
m_szTextLines.clear();
|
m_szTextLines.clear();
|
||||||
m_iLineWidths.clear();
|
split(CStringToWstring(m_szText), L"\n", m_szTextLines, false);
|
||||||
|
|
||||||
split(CStringToWstring(sText), L"\n", m_szTextLines, false);
|
|
||||||
|
|
||||||
BuildChars();
|
BuildChars();
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -26,7 +26,7 @@ public:
|
|||||||
bool LoadFromFont( CString sFontName );
|
bool LoadFromFont( CString sFontName );
|
||||||
bool LoadFromNumbers( CString sTexturePath ) { return LoadFromTextureAndChars(sTexturePath,"0123456789%. :x"); };
|
bool LoadFromNumbers( CString sTexturePath ) { return LoadFromTextureAndChars(sTexturePath,"0123456789%. :x"); };
|
||||||
bool LoadFromTextureAndChars( CString sTexturePath, CString sChars );
|
bool LoadFromTextureAndChars( CString sTexturePath, CString sChars );
|
||||||
void SetText( CString sText );
|
void SetText( CString sText, CString sAlternateText = "" );
|
||||||
|
|
||||||
int GetWidestLineWidthInSourcePixels() { return m_iWidestLineWidth; };
|
int GetWidestLineWidthInSourcePixels() { return m_iWidestLineWidth; };
|
||||||
void CropToWidth( int iWidthInSourcePixels );
|
void CropToWidth( int iWidthInSourcePixels );
|
||||||
@@ -39,8 +39,9 @@ public:
|
|||||||
void SetHorizAlign( HorizAlign ha );
|
void SetHorizAlign( HorizAlign ha );
|
||||||
void SetVertAlign( VertAlign va );
|
void SetVertAlign( VertAlign va );
|
||||||
|
|
||||||
|
CString GetText() const { return m_szText; }
|
||||||
|
|
||||||
public:
|
public:
|
||||||
CString m_sFontFilePath;
|
|
||||||
Font* m_pFont;
|
Font* m_pFont;
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
|
|||||||
Reference in New Issue
Block a user