add StringWillUseAlternate
This commit is contained in:
@@ -231,12 +231,8 @@ 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(StringWillUseAlternate(sText, sAlternateText))
|
||||
sText = sAlternateText;
|
||||
|
||||
if(m_szText == sText)
|
||||
return;
|
||||
@@ -250,6 +246,22 @@ void BitmapText::SetText( CString sText, CString sAlternateText )
|
||||
BuildChars();
|
||||
}
|
||||
|
||||
bool BitmapText::StringWillUseAlternate(CString sText, CString sAlternateText) const
|
||||
{
|
||||
ASSERT( m_pFont );
|
||||
|
||||
/* Can't use the alternate if there isn't one. */
|
||||
if(!sAlternateText.size()) return false;
|
||||
|
||||
/* False if the alternate isn't needed. */
|
||||
if(m_pFont->FontCompleteForString(CStringToWstring(sText))) return false;
|
||||
|
||||
/* False if the alternate is also incomplete. */
|
||||
if(!m_pFont->FontCompleteForString(CStringToWstring(sAlternateText))) return false;
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
void BitmapText::CropToWidth( int iMaxWidthInSourcePixels )
|
||||
{
|
||||
iMaxWidthInSourcePixels = max( 0, iMaxWidthInSourcePixels );
|
||||
|
||||
@@ -40,6 +40,8 @@ public:
|
||||
void SetVertAlign( VertAlign va );
|
||||
|
||||
CString GetText() const { return m_szText; }
|
||||
/* Return true if the string 's' will use an alternate string, if available. */
|
||||
bool StringWillUseAlternate(CString sText, CString sAlternateText) const;
|
||||
|
||||
public:
|
||||
Font* m_pFont;
|
||||
|
||||
Reference in New Issue
Block a user