use glyph and width of '0' for ' ' in number fonts (a leading zero)
This commit is contained in:
@@ -101,9 +101,10 @@ static const wchar_t map_iso_8859_2[] = {
|
||||
};
|
||||
|
||||
static const wchar_t map_numbers[] = {
|
||||
0x0030, 0x0031, 0x0032, 0x0033, 0x0034,
|
||||
0x0035, 0x0036, 0x0037, 0x0038, 0x0039,
|
||||
0x0025, 0x002E, 0x0020, 0x003A, 0x0078,
|
||||
0x0030, 0x0031, 0x0032, 0x0033,
|
||||
0x0034, 0x0035, 0x0036, 0x0037,
|
||||
0x0038, 0x0039, 0x0025, 0x002E,
|
||||
0x0020, 0x003A, 0x0078, 0x002C,
|
||||
0
|
||||
};
|
||||
|
||||
@@ -152,8 +153,9 @@ void CTextureFontGeneratorDlg::UpdateFont( bool bSavingDoubleRes )
|
||||
for( int i = 0; map_cp1252[i]; ++i )
|
||||
{
|
||||
wchar_t wc = map_cp1252[i];
|
||||
FontPageDescription::Char c = { wc, wc };
|
||||
if( wc != 0xFFFF )
|
||||
desc.chars.push_back(wc);
|
||||
desc.chars.push_back(c);
|
||||
}
|
||||
g_pTextureFont->m_PagesToGenerate.push_back( desc );
|
||||
|
||||
@@ -162,8 +164,9 @@ void CTextureFontGeneratorDlg::UpdateFont( bool bSavingDoubleRes )
|
||||
for( int i = 0; map_iso_8859_2[i]; ++i )
|
||||
{
|
||||
wchar_t wc = map_iso_8859_2[i];
|
||||
FontPageDescription::Char c = { wc, wc };
|
||||
if( wc != 0xFFFF )
|
||||
desc.chars.push_back(wc);
|
||||
desc.chars.push_back(c);
|
||||
}
|
||||
g_pTextureFont->m_PagesToGenerate.push_back( desc );
|
||||
}
|
||||
@@ -174,8 +177,11 @@ void CTextureFontGeneratorDlg::UpdateFont( bool bSavingDoubleRes )
|
||||
for( int i = 0; map_numbers[i]; ++i )
|
||||
{
|
||||
wchar_t wc = map_numbers[i];
|
||||
FontPageDescription::Char c = { wc, wc };
|
||||
if( wc == 0x0020 ) // space
|
||||
c.glyphAndWidth = 0x0030; // '0'
|
||||
if( wc != 0xFFFF )
|
||||
desc.chars.push_back(wc);
|
||||
desc.chars.push_back(c);
|
||||
}
|
||||
g_pTextureFont->m_PagesToGenerate.push_back( desc );
|
||||
}
|
||||
|
||||
@@ -281,7 +281,7 @@ void TextureFont::FormatFontPage( int iPage, HDC hDC )
|
||||
|
||||
/* First, generate bitmaps for all characters in this page. */
|
||||
for( unsigned i = 0; i < Desc.chars.size(); ++i )
|
||||
FormatCharacter( Desc.chars[i], hDC );
|
||||
FormatCharacter( Desc.chars[i].glyphAndWidth, hDC );
|
||||
|
||||
FontPage *pPage = m_apPages[iPage];
|
||||
pPage->m_iFrameWidth = (m_BoundingRect.right - m_BoundingRect.left) + m_iPadding;
|
||||
@@ -302,7 +302,7 @@ void TextureFont::FormatFontPage( int iPage, HDC hDC )
|
||||
int iRow = 0, iCol = 0;
|
||||
for( unsigned CurChar = 0; CurChar < Desc.chars.size(); ++CurChar )
|
||||
{
|
||||
const wchar_t c = Desc.chars[CurChar];
|
||||
const wchar_t c = Desc.chars[CurChar].glyphAndWidth;
|
||||
const ABC &abc = m_ABC[c];
|
||||
|
||||
/* The current frame is at fOffsetX/fOffsetY. Center the character
|
||||
@@ -418,7 +418,7 @@ void TextureFont::Save( CString sBasePath, CString sBitmapAppendBeforeExtension,
|
||||
f << setw(1);
|
||||
for( int iX = 0; iX < page.m_iNumFramesX && iChar < desc.chars.size(); ++iX, ++iChar )
|
||||
{
|
||||
const wchar_t c = desc.chars[iChar];
|
||||
const wchar_t c = desc.chars[iChar].codepoint;
|
||||
string sUTF8;
|
||||
wchar_to_utf8( c, sUTF8 );
|
||||
f << sUTF8.c_str();
|
||||
@@ -433,7 +433,7 @@ void TextureFont::Save( CString sBasePath, CString sBitmapAppendBeforeExtension,
|
||||
{
|
||||
/* This is the total width to advance for the whole character, which is the
|
||||
* sum of the ABC widths. */
|
||||
const wchar_t c = desc.chars[j];
|
||||
const wchar_t c = desc.chars[j].glyphAndWidth;
|
||||
ABC &abc = m_ABC[c];
|
||||
int iCharWidth = abc.abcA + int(abc.abcB) + int(abc.abcC);
|
||||
f << j << "=" << iCharWidth << "\n";
|
||||
|
||||
@@ -8,7 +8,13 @@ using namespace std;
|
||||
struct FontPageDescription
|
||||
{
|
||||
CString name;
|
||||
vector<wchar_t> chars;
|
||||
struct Char
|
||||
{
|
||||
// Glyph and code point may differ. For example, we may want to render ' ' as '0' in a numbers font to achieve a leading '0' character that can be styled differently from regular '0'.
|
||||
wchar_t glyphAndWidth;
|
||||
wchar_t codepoint;
|
||||
};
|
||||
vector<Char> chars;
|
||||
};
|
||||
|
||||
struct FontPage
|
||||
|
||||
Reference in New Issue
Block a user