use int instead of wchar_t; don't want to be limited to 16-bit
This commit is contained in:
@@ -116,7 +116,7 @@ void BitmapText::BuildChars()
|
||||
|
||||
for( i=0; i<m_szTextLines.size(); i++ ) // foreach line
|
||||
{
|
||||
const wstring &szLine = m_szTextLines[i];
|
||||
const lstring &szLine = m_szTextLines[i];
|
||||
const int iLineWidth = m_iLineWidths[i];
|
||||
|
||||
int iX;
|
||||
@@ -185,7 +185,8 @@ void BitmapText::SetText( CString sText )
|
||||
m_iLineWidths.clear();
|
||||
m_iLineHeights.clear();
|
||||
|
||||
split(CStringToWstring(sText), L"\n", m_szTextLines, false);
|
||||
lstring s; s.push_back('\n');
|
||||
split(CStringToLstring(sText), s, m_szTextLines, false);
|
||||
|
||||
/* calculate line lengths and widths */
|
||||
m_iWidestLineWidth = 0;
|
||||
|
||||
@@ -47,7 +47,7 @@ protected:
|
||||
|
||||
// recalculate the items below on SetText()
|
||||
CString m_szText;
|
||||
vector<wstring> m_szTextLines;
|
||||
vector<lstring> m_szTextLines;
|
||||
vector<int> m_iLineWidths; // in source pixels
|
||||
vector<int> m_iLineHeights; // in source pixels
|
||||
int m_iWidestLineWidth; // in source pixels
|
||||
|
||||
+10
-10
@@ -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<wchar_t,int>::const_iterator it = fp->m_iCharToGlyphNo.begin();
|
||||
for(map<longchar,int>::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<wchar_t,glyph*>::iterator it = f->m_iCharToGlyph.begin();
|
||||
for(map<longchar,glyph*>::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<wchar_t,glyph*>::const_iterator it = m_iCharToGlyph.find(c);
|
||||
map<longchar,glyph*>::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<wchar_t,glyph*>::iterator it = m_iCharToGlyph.find(c);
|
||||
map<longchar,glyph*>::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<wchar_t,glyph*>::const_iterator it = m_iCharToGlyph.find(c);
|
||||
map<longchar,glyph*>::const_iterator it = m_iCharToGlyph.find(c);
|
||||
|
||||
if(it == m_iCharToGlyph.end())
|
||||
continue;
|
||||
|
||||
+9
-10
@@ -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<wchar_t,int> CharToGlyphNo;
|
||||
map<longchar,int> CharToGlyphNo;
|
||||
/* If a value is missing, the width of the texture frame is used. */
|
||||
map<int,int> GlyphWidths;
|
||||
|
||||
@@ -49,8 +50,6 @@ struct FontPageSettings {
|
||||
{ }
|
||||
};
|
||||
|
||||
// typedef basic_string<wchar_t> wstring;
|
||||
|
||||
class FontPage
|
||||
{
|
||||
public:
|
||||
@@ -61,7 +60,7 @@ public:
|
||||
/* All glyphs in this list will point to m_pTexture. */
|
||||
vector<glyph> glyphs;
|
||||
|
||||
map<wchar_t,int> m_iCharToGlyphNo;
|
||||
map<longchar,int> m_iCharToGlyphNo;
|
||||
|
||||
FontPage();
|
||||
~FontPage();
|
||||
@@ -78,16 +77,16 @@ class Font
|
||||
public:
|
||||
int m_iRefCount;
|
||||
CString path;
|
||||
map<wchar_t,glyph*> m_iCharToGlyph;
|
||||
map<longchar,glyph*> 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. */
|
||||
|
||||
@@ -20,7 +20,7 @@
|
||||
#include "RageTimer.h"
|
||||
#include "ThemeManager.h"
|
||||
|
||||
static map <CString, wchar_t, StdStringLessNoCase> CharAliases;
|
||||
static map <CString, longchar, StdStringLessNoCase> 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<NumFrames; i++ )
|
||||
for( longchar i=0; i<NumFrames; i++ )
|
||||
cfg.CharToGlyphNo[i] = i;
|
||||
}
|
||||
ini.RenameKey("Char Widths", "main");
|
||||
@@ -94,7 +94,7 @@ void FontManager::LoadFontPageSettings(FontPageSettings &cfg, IniFile &ini, cons
|
||||
*/
|
||||
CString codepoint = val.substr(4); /* "XXXX" */
|
||||
|
||||
wchar_t c;
|
||||
longchar c;
|
||||
|
||||
if(codepoint.substr(0, 2) == "U+" && IsHexVal(codepoint.substr(2)))
|
||||
sscanf(codepoint.substr(2).c_str(), "%x", &c);
|
||||
|
||||
+10
-11
@@ -177,7 +177,7 @@ void split( const CString &Source, const CString &Deliminator, CStringArray &Add
|
||||
do_split(Source, Deliminator, AddIt, bIgnoreEmpty );
|
||||
}
|
||||
|
||||
void split( const wstring &Source, const wstring &Deliminator, vector<wstring> &AddIt, const bool bIgnoreEmpty )
|
||||
void split( const lstring &Source, const lstring &Deliminator, vector<lstring> &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;
|
||||
|
||||
@@ -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<longchar> 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<wstring> &AddIt, const bool bIgnoreEmpty = true );
|
||||
void split( const lstring &Source, const lstring &Deliminator, vector<lstring> &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<CString> &matches);
|
||||
bool regex(CString str, CString pattern);
|
||||
void regex_flags(int flags);
|
||||
|
||||
wstring CStringToWstring(const CString &str);
|
||||
|
||||
#ifndef WIN32
|
||||
#include <unistd.h> /* correct place with correct definitions */
|
||||
#endif
|
||||
|
||||
Reference in New Issue
Block a user