Added new function to simulate bold fonts.
git-svn-id: svn+ssh://svn.code.sf.net/p/supertuxkart/code/trunk/supertuxkart@1817 178a84e3-b1eb-0310-8ba1-8eac791a3b58
This commit is contained in:
parent
a41ce77029
commit
823110be8b
@ -112,5 +112,54 @@ void Font::Print(const char *text, int size,
|
||||
m_text_out->end();
|
||||
|
||||
} // Print
|
||||
|
||||
// -----------------------------------------------------------------------------
|
||||
|
||||
void Font::PrintBold(const std::string &text, int size, int x, int y,
|
||||
const GLfloat* color, float scale_x, float scale_y,
|
||||
int left, int right, int top, int bottom )
|
||||
{
|
||||
// Only scale for lower resolution
|
||||
float fontScaling = user_config->m_width<800 ? ((float)user_config->m_width/800.0f)
|
||||
: 1.0f;
|
||||
int sz = (int)(size*std::max(scale_x,scale_y)*fontScaling);
|
||||
|
||||
float l,r,t,b;
|
||||
m_fnt->getBBox(text.c_str(), (float)sz, 0, &l, &r, &b, &t);
|
||||
const int W = (int)((r-l+0.99));
|
||||
const int H = (int)((t-b+0.99));
|
||||
|
||||
if(x==CENTER_OF_SCREEN)
|
||||
{
|
||||
if(left ==-1) left = 0;
|
||||
if(right==-1) right = user_config->m_width-1;
|
||||
int width = right-left+1;
|
||||
x = (width - W)/2 + left;
|
||||
}
|
||||
|
||||
if(y==CENTER_OF_SCREEN)
|
||||
{
|
||||
if(top == -1) top = user_config->m_height-1;
|
||||
if(bottom == -1) bottom = 0;
|
||||
int height = top-bottom+1;
|
||||
y = (height - H)/2 + bottom;
|
||||
}
|
||||
|
||||
|
||||
m_text_out->begin();
|
||||
m_text_out->setPointSize((float)sz);
|
||||
if( color == NULL )
|
||||
{
|
||||
glColor4f(1.0f,1.0f,1.0f,1.0f);
|
||||
}
|
||||
else
|
||||
{
|
||||
glColor4fv(color);
|
||||
}
|
||||
for(float r=-1; r<=0; r+=0.5)
|
||||
{
|
||||
m_text_out->start2f((GLfloat)x-r, (GLfloat)y-r);
|
||||
m_text_out->puts(text.c_str());
|
||||
}
|
||||
m_text_out->end();
|
||||
|
||||
} // PrintBold
|
||||
|
@ -73,6 +73,11 @@ public:
|
||||
color, scale_x, scale_y,
|
||||
left, right, top, bottom, true);
|
||||
}
|
||||
void PrintBold( std::string const &text, int size,
|
||||
int x, int y,
|
||||
const GLfloat* color = NULL,
|
||||
float scale_x=1.0f, float scale_y=1.0f,
|
||||
int left=-1, int right=-1, int top=-1, int bottom=-1);
|
||||
};
|
||||
|
||||
int init_fonts();
|
||||
|
Loading…
x
Reference in New Issue
Block a user