Changed a function that the GUI uses to Unicode.
This was SVN commit r1127.
This commit is contained in:
parent
da465ae1dc
commit
6e07632775
@ -1,5 +1,5 @@
|
||||
/*
|
||||
$Id: unifont.cpp,v 1.15 2004/09/04 20:34:57 philip Exp $
|
||||
$Id: unifont.cpp,v 1.16 2004/09/06 02:24:05 gee Exp $
|
||||
|
||||
Unicode OpenGL texture font
|
||||
|
||||
@ -248,7 +248,7 @@ void glwprintf(const wchar_t* fmt, ...)
|
||||
glCallLists((GLsizei)len, sizeof(wchar_t)==4 ? GL_INT : GL_UNSIGNED_SHORT, buf);
|
||||
}
|
||||
|
||||
|
||||
#if 0 // Replaced by the unicode version, this can be removed /Gee
|
||||
int unifont_stringsize(const Handle h, const char* text, int& width, int& height)
|
||||
{
|
||||
H_DEREF(h, UniFont, f);
|
||||
@ -276,3 +276,35 @@ int unifont_stringsize(const Handle h, const char* text, int& width, int& height
|
||||
|
||||
return 0;
|
||||
}
|
||||
#endif
|
||||
|
||||
int unifont_stringsize(const Handle h, const wchar_t* text, int& width, int& height)
|
||||
{
|
||||
H_DEREF(h, UniFont, f);
|
||||
|
||||
width = 0;
|
||||
height = f->Height;
|
||||
|
||||
size_t len = wcslen(text);
|
||||
|
||||
for (size_t i = 0; i < len; ++i)
|
||||
{
|
||||
glyphmap_size::iterator it = f->glyphs_size->find(text[i]);
|
||||
|
||||
if (it == f->glyphs_size->end())
|
||||
it = f->glyphs_size->find(0xFFFD); // Use the missing glyph symbol
|
||||
|
||||
if (it == f->glyphs_size->end()) // Missing the missing glyph symbol - give up
|
||||
{
|
||||
debug_warn("Missing the missing glyph in a unifont!\n");
|
||||
return 0;
|
||||
}
|
||||
|
||||
width += it->second; // Add the character's advance distance
|
||||
}
|
||||
|
||||
LOG_ONCE(ERROR, LOG_CATEGORY, "%d %d", width, height);
|
||||
|
||||
return 0;
|
||||
}
|
||||
// -- GL
|
@ -1,4 +1,4 @@
|
||||
// $Id: unifont.h,v 1.5 2004/09/04 20:34:57 philip Exp $
|
||||
// $Id: unifont.h,v 1.6 2004/09/06 02:24:05 gee Exp $
|
||||
|
||||
#ifndef __UNIFONT_H__
|
||||
#define __UNIFONT_H__
|
||||
@ -34,9 +34,9 @@ void glwprintf(const wchar_t* fmt, ...);
|
||||
glTexEnvi(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_MODULATE);
|
||||
*/
|
||||
|
||||
// Intended for the GUI (hence ASCIIness). 'height' is roughly the height of
|
||||
// Intended for the GUI (hence Unicode). 'height' is roughly the height of
|
||||
// a capital letter, for use when aligning text in an aesthetically pleasing way.
|
||||
int unifont_stringsize(const Handle h, const char* text, int& width, int& height);
|
||||
int unifont_stringsize(const Handle h, const wchar_t* text, int& width, int& height);
|
||||
|
||||
// Return spacing in pixels from one line of text to the next
|
||||
int unifont_linespacing(const Handle h);
|
||||
|
@ -66,7 +66,7 @@ int CFont::GetLineSpacing()
|
||||
return unifont_linespacing(h);
|
||||
}
|
||||
|
||||
void CFont::CalculateStringSize(const CStr& string, int& width, int& height)
|
||||
void CFont::CalculateStringSize(const CStrW& string, int& width, int& height)
|
||||
{
|
||||
unifont_stringsize(h, string.c_str(), width, height);
|
||||
}
|
||||
unifont_stringsize(h, (const wchar_t*)string, width, height);
|
||||
}
|
@ -29,7 +29,7 @@ public:
|
||||
|
||||
void Bind();
|
||||
int GetLineSpacing();
|
||||
void CalculateStringSize(const CStr& string, int& w, int& h);
|
||||
void CalculateStringSize(const CStrW& string, int& w, int& h);
|
||||
|
||||
private:
|
||||
Handle h;
|
||||
|
Loading…
Reference in New Issue
Block a user