add StringWillUseAlternate

This commit is contained in:
Glenn Maynard
2003-02-12 20:19:20 +00:00
parent af5fa1db3c
commit 7a3336d50d
2 changed files with 20 additions and 6 deletions
+17 -5
View File
@@ -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 );
+2
View File
@@ -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;