From d46a2ef9deee37e8274d594d8632cb16eb0ebd9a Mon Sep 17 00:00:00 2001 From: Glenn Maynard Date: Sun, 5 Jan 2003 08:11:05 +0000 Subject: [PATCH] use int instead of wchar_t; don't want to be limited to 16-bit --- stepmania/src/BitmapText.cpp | 5 +++-- stepmania/src/BitmapText.h | 2 +- stepmania/src/Font.cpp | 20 ++++++++++---------- stepmania/src/Font.h | 19 +++++++++---------- stepmania/src/FontManager.cpp | 6 +++--- stepmania/src/RageUtil.cpp | 21 ++++++++++----------- stepmania/src/RageUtil.h | 11 ++++++++--- 7 files changed, 44 insertions(+), 40 deletions(-) diff --git a/stepmania/src/BitmapText.cpp b/stepmania/src/BitmapText.cpp index 1f1ceb6c42..1387b11d74 100644 --- a/stepmania/src/BitmapText.cpp +++ b/stepmania/src/BitmapText.cpp @@ -116,7 +116,7 @@ void BitmapText::BuildChars() for( i=0; i m_szTextLines; + vector m_szTextLines; vector m_iLineWidths; // in source pixels vector m_iLineHeights; // in source pixels int m_iWidestLineWidth; // in source pixels diff --git a/stepmania/src/Font.cpp b/stepmania/src/Font.cpp index f1877e9aff..723b1b896b 100644 --- a/stepmania/src/Font.cpp +++ b/stepmania/src/Font.cpp @@ -20,7 +20,7 @@ #include "RageException.h" #include "FontManager.h" -const wchar_t Font::DEFAULT_GLYPH = 0xFFFF; +const longchar Font::DEFAULT_GLYPH = 0xFFFF; FontPage::FontPage() { @@ -158,7 +158,7 @@ FontPage::~FontPage() } -int Font::GetLineWidthInSourcePixels( const wstring &szLine ) const +int Font::GetLineWidthInSourcePixels( const lstring &szLine ) const { int LineWidth = 0; @@ -168,7 +168,7 @@ int Font::GetLineWidthInSourcePixels( const wstring &szLine ) const return LineWidth; } -int Font::GetLineHeightInSourcePixels( const wstring &szLine ) const +int Font::GetLineHeightInSourcePixels( const lstring &szLine ) const { int iLineSpacing = 0; @@ -201,7 +201,7 @@ void Font::AddPage(FontPage *fp) { pages.push_back(fp); - for(map::const_iterator it = fp->m_iCharToGlyphNo.begin(); + for(map::const_iterator it = fp->m_iCharToGlyphNo.begin(); it != fp->m_iCharToGlyphNo.end(); ++it) { m_iCharToGlyph[it->first] = &fp->glyphs[it->second]; @@ -210,7 +210,7 @@ void Font::AddPage(FontPage *fp) void Font::MergeFont(Font *f) { - for(map::iterator it = f->m_iCharToGlyph.begin(); + for(map::iterator it = f->m_iCharToGlyph.begin(); it != f->m_iCharToGlyph.end(); ++it) { m_iCharToGlyph[it->first] = it->second; @@ -220,9 +220,9 @@ void Font::MergeFont(Font *f) merged_fonts.push_back(f); } -const glyph &Font::GetGlyph( wchar_t c ) const +const glyph &Font::GetGlyph( longchar c ) const { - map::const_iterator it = m_iCharToGlyph.find(c); + map::const_iterator it = m_iCharToGlyph.find(c); if(it == m_iCharToGlyph.end()) { @@ -234,9 +234,9 @@ const glyph &Font::GetGlyph( wchar_t c ) const return *it->second; } -RageTexture *Font::GetGlyphTexture( wchar_t c ) +RageTexture *Font::GetGlyphTexture( longchar c ) { - map::iterator it = m_iCharToGlyph.find(c); + map::iterator it = m_iCharToGlyph.find(c); if(it == m_iCharToGlyph.end()) { @@ -254,7 +254,7 @@ void Font::CapsOnly() * a lowercase one. */ for(char c = 'A'; c <= 'Z'; ++c) { - map::const_iterator it = m_iCharToGlyph.find(c); + map::const_iterator it = m_iCharToGlyph.find(c); if(it == m_iCharToGlyph.end()) continue; diff --git a/stepmania/src/Font.h b/stepmania/src/Font.h index efe6df6ad3..c2d4677f1b 100644 --- a/stepmania/src/Font.h +++ b/stepmania/src/Font.h @@ -12,6 +12,7 @@ */ #include "RageTexture.h" +#include "RageUtil.h" #include "IniFile.h" struct glyph { @@ -37,7 +38,7 @@ struct FontPageSettings { LineSpacing; float ScaleAllWidthsBy; - map CharToGlyphNo; + map CharToGlyphNo; /* If a value is missing, the width of the texture frame is used. */ map GlyphWidths; @@ -49,8 +50,6 @@ struct FontPageSettings { { } }; -// typedef basic_string wstring; - class FontPage { public: @@ -61,7 +60,7 @@ public: /* All glyphs in this list will point to m_pTexture. */ vector glyphs; - map m_iCharToGlyphNo; + map m_iCharToGlyphNo; FontPage(); ~FontPage(); @@ -78,16 +77,16 @@ class Font public: int m_iRefCount; CString path; - map m_iCharToGlyph; + map m_iCharToGlyph; Font(); ~Font(); - RageTexture *GetGlyphTexture( wchar_t c ); - const glyph &GetGlyph( wchar_t c ) const; + RageTexture *GetGlyphTexture( longchar c ); + const glyph &GetGlyph( longchar c ) const; - int GetLineWidthInSourcePixels( const wstring &szLine ) const; - int GetLineHeightInSourcePixels( const wstring &szLine ) const; + int GetLineWidthInSourcePixels( const lstring &szLine ) const; + int GetLineHeightInSourcePixels( const lstring &szLine ) const; /* Add a FontPage to this font. */ void AddPage(FontPage *fp); @@ -98,7 +97,7 @@ public: /* Load font-wide settings. */ void CapsOnly(); - static const wchar_t DEFAULT_GLYPH; + static const longchar DEFAULT_GLYPH; private: /* List of pages and fonts that we're responsible for freeing. */ diff --git a/stepmania/src/FontManager.cpp b/stepmania/src/FontManager.cpp index e67938b857..a7c06599dd 100644 --- a/stepmania/src/FontManager.cpp +++ b/stepmania/src/FontManager.cpp @@ -20,7 +20,7 @@ #include "RageTimer.h" #include "ThemeManager.h" -static map CharAliases; +static map CharAliases; FontManager* FONT = NULL; @@ -54,7 +54,7 @@ void FontManager::LoadFontPageSettings(FontPageSettings &cfg, IniFile &ini, cons else if(NumFrames == 256) cfg.MapRange("ISO-8859-1", 0, 255, 0); */ - for( wchar_t i=0; i &AddIt, const bool bIgnoreEmpty ) +void split( const lstring &Source, const lstring &Deliminator, vector &AddIt, const bool bIgnoreEmpty ) { do_split(Source, Deliminator, AddIt, bIgnoreEmpty ); } @@ -871,10 +871,10 @@ char *utf8_find_next_char (const char *p, const char *end) #define UTF8_GET \ -wchar_t utf8_get_char (const char *p) +longchar utf8_get_char (const char *p) { int i, mask = 0, len; - wchar_t result; + longchar result; unsigned char c = (unsigned char) *p; if (c < 128) { @@ -896,12 +896,12 @@ wchar_t utf8_get_char (const char *p) len = 6; mask = 0x01; } else - return (wchar_t)-1; + return (longchar)-1; - result = wchar_t(p[0] & mask); + result = longchar(p[0] & mask); for (i = 1; i < len; ++i) { if ((p[i] & 0xc0) != 0x80) - return (wchar_t) -1; + return (longchar) -1; result <<= 6; result |= p[i] & 0x3f; @@ -910,20 +910,19 @@ wchar_t utf8_get_char (const char *p) return result; } -wstring CStringToWstring(const CString &str) +lstring CStringToLstring(const CString &str) { const char *ptr = str.c_str(), *end = str.c_str()+str.size(); - wstring ret; + lstring ret; while(ptr) { - wchar_t c = utf8_get_char (ptr); - if(c != wchar_t(-1)) + longchar c = utf8_get_char (ptr); + if(c != longchar(-1)) ret.push_back(c); ptr = utf8_find_next_char (ptr, end); - } return ret; diff --git a/stepmania/src/RageUtil.h b/stepmania/src/RageUtil.h index c9715faa2c..9fcf383965 100644 --- a/stepmania/src/RageUtil.h +++ b/stepmania/src/RageUtil.h @@ -148,6 +148,13 @@ void splitrelpath( CString& Ext ); +/* This is our version of wchar_t. We work in UCS4, and wchar_t may only + * be 16-bit. This is mostly used within the font and text system. */ +typedef int longchar; +typedef basic_string lstring; + +lstring CStringToLstring(const CString &str); + // Splits a CString into an CStringArray according the Deliminator. void split( const CString &Source, @@ -155,7 +162,7 @@ void split( CStringArray& AddIt, const bool bIgnoreEmpty = true ); -void split( const wstring &Source, const wstring &Deliminator, vector &AddIt, const bool bIgnoreEmpty = true ); +void split( const lstring &Source, const lstring &Deliminator, vector &AddIt, const bool bIgnoreEmpty = true ); // Joins a CStringArray to create a CString according the Deliminator. CString join( @@ -197,8 +204,6 @@ bool regex(CString str, CString pattern, vector &matches); bool regex(CString str, CString pattern); void regex_flags(int flags); -wstring CStringToWstring(const CString &str); - #ifndef WIN32 #include /* correct place with correct definitions */ #endif