add StringWillUseAlternate
This commit is contained in:
@@ -231,12 +231,8 @@ void BitmapText::SetText( CString sText, CString sAlternateText )
|
|||||||
{
|
{
|
||||||
ASSERT( m_pFont );
|
ASSERT( m_pFont );
|
||||||
|
|
||||||
if(sAlternateText.size())
|
if(StringWillUseAlternate(sText, sAlternateText))
|
||||||
{
|
|
||||||
if(!m_pFont->FontCompleteForString(CStringToWstring(sText)) &&
|
|
||||||
m_pFont->FontCompleteForString(CStringToWstring(sAlternateText)))
|
|
||||||
sText = sAlternateText;
|
sText = sAlternateText;
|
||||||
}
|
|
||||||
|
|
||||||
if(m_szText == sText)
|
if(m_szText == sText)
|
||||||
return;
|
return;
|
||||||
@@ -250,6 +246,22 @@ void BitmapText::SetText( CString sText, CString sAlternateText )
|
|||||||
BuildChars();
|
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 )
|
void BitmapText::CropToWidth( int iMaxWidthInSourcePixels )
|
||||||
{
|
{
|
||||||
iMaxWidthInSourcePixels = max( 0, iMaxWidthInSourcePixels );
|
iMaxWidthInSourcePixels = max( 0, iMaxWidthInSourcePixels );
|
||||||
|
|||||||
@@ -40,6 +40,8 @@ public:
|
|||||||
void SetVertAlign( VertAlign va );
|
void SetVertAlign( VertAlign va );
|
||||||
|
|
||||||
CString GetText() const { return m_szText; }
|
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:
|
public:
|
||||||
Font* m_pFont;
|
Font* m_pFont;
|
||||||
|
|||||||
Reference in New Issue
Block a user