make a Font charmap for numbers fonts

This commit is contained in:
Chris Danford
2004-05-31 00:11:34 +00:00
parent 3cadf4c5d5
commit 93e274b3ac
3 changed files with 151 additions and 145 deletions
-8
View File
@@ -88,13 +88,6 @@ bool BitmapText::LoadFromFont( CString sFontFilePath )
{ {
CHECKPOINT_M( ssprintf("BitmapText::LoadFromFont(%s)", sFontFilePath.c_str()) ); CHECKPOINT_M( ssprintf("BitmapText::LoadFromFont(%s)", sFontFilePath.c_str()) );
// if we're called with a non-ini file, then we're trying to load a 5x3 numbers graphic
bool bIsNumbers = GetExtension(sFontFilePath).CompareNoCase("ini")!=0;
if( bIsNumbers )
{
return LoadFromTextureAndChars( sFontFilePath, "0123456789%. :x" );
}
if( m_pFont ) { if( m_pFont ) {
FONT->UnloadFont( m_pFont ); FONT->UnloadFont( m_pFont );
m_pFont = NULL; m_pFont = NULL;
@@ -117,7 +110,6 @@ bool BitmapText::LoadFromTextureAndChars( CString sTexturePath, CString sChars )
m_pFont = NULL; m_pFont = NULL;
} }
// load font
m_pFont = FONT->LoadFont( sTexturePath, sChars ); m_pFont = FONT->LoadFont( sTexturePath, sChars );
BuildChars(); BuildChars();
+8 -4
View File
@@ -491,9 +491,8 @@ void Font::LoadFontPageSettings(FontPageSettings &cfg, IniFile &ini, const CStri
/* Iterate over all keys. */ /* Iterate over all keys. */
const IniFile::key *k = ini.GetKey(PageName); const IniFile::key *k = ini.GetKey(PageName);
if(k == NULL) if( k )
return; {
for(IniFile::key::const_iterator key = k->begin(); key != k->end(); ++key) for(IniFile::key::const_iterator key = k->begin(); key != k->end(); ++key)
{ {
CString val = key->first; CString val = key->first;
@@ -649,6 +648,7 @@ void Font::LoadFontPageSettings(FontPageSettings &cfg, IniFile &ini, const CStri
cfg.CharToGlyphNo[wdata[i]] = first_frame+i; cfg.CharToGlyphNo[wdata[i]] = first_frame+i;
} }
} }
}
/* If it's 128 or 256 frames, default to ASCII or CP1252, /* If it's 128 or 256 frames, default to ASCII or CP1252,
* respectively. If it's anything else, we don't know what it * respectively. If it's anything else, we don't know what it
@@ -658,6 +658,8 @@ void Font::LoadFontPageSettings(FontPageSettings &cfg, IniFile &ini, const CStri
cfg.MapRange("ascii", 0, 0, -1); cfg.MapRange("ascii", 0, 0, -1);
else if(cfg.CharToGlyphNo.empty() && NumFrames == 256) else if(cfg.CharToGlyphNo.empty() && NumFrames == 256)
cfg.MapRange("cp1252", 0, 0, -1); cfg.MapRange("cp1252", 0, 0, -1);
else if(cfg.CharToGlyphNo.empty() && NumFrames == 15)
cfg.MapRange("numbers", 0, 0, -1);
/* If ' ' is set and nbsp is not, set nbsp. */ /* If ' ' is set and nbsp is not, set nbsp. */
if( cfg.CharToGlyphNo.find(' ') != cfg.CharToGlyphNo.end() ) if( cfg.CharToGlyphNo.find(' ') != cfg.CharToGlyphNo.end() )
@@ -818,10 +820,12 @@ void Font::Load(const CString &sFontOrTextureFilePath, CString sChars)
/* Load each font page. */ /* Load each font page. */
for(unsigned i = 0; i < TexturePaths.size(); ++i) for(unsigned i = 0; i < TexturePaths.size(); ++i)
{ {
const CString sTexturePath = TexturePaths[i];
FontPage *fp = new FontPage; FontPage *fp = new FontPage;
/* Grab the page name, eg "foo" from "Normal [foo].png". */ /* Grab the page name, eg "foo" from "Normal [foo].png". */
CString pagename = GetPageNameFromFileName(TexturePaths[i]); CString pagename = GetPageNameFromFileName(sTexturePath);
/* Load settings for this page from the INI. */ /* Load settings for this page from the INI. */
FontPageSettings cfg; FontPageSettings cfg;
+10
View File
@@ -136,6 +136,15 @@ static const wchar_t map_korean_jamo[] =
0 0
}; };
/* Numbers. "0123456789%. :x" */
static const wchar_t map_numbers[] = {
0x0030, 0x0031, 0x0032, 0x0033, 0x0034,
0x0035, 0x0036, 0x0037, 0x0038, 0x0039,
0x0025, 0x002E, 0x0020, 0x003A, 0x0078,
0
};
static void Init() static void Init()
{ {
if(!charmaps.empty()) if(!charmaps.empty())
@@ -147,6 +156,7 @@ static void Init()
charmaps["cp1252"] = map_cp1252; charmaps["cp1252"] = map_cp1252;
charmaps["iso-8859-2"] = map_iso_8859_2; charmaps["iso-8859-2"] = map_iso_8859_2;
charmaps["korean-jamo"] = map_korean_jamo; charmaps["korean-jamo"] = map_korean_jamo;
charmaps["numbers"] = map_numbers;
} }
const wchar_t *FontCharmaps::get_char_map(CString name) const wchar_t *FontCharmaps::get_char_map(CString name)