[Bf-python] Smooth fonts
Campbell Barton
cbarton at metavr.com
Thu Jan 12 08:18:22 CET 2006
Added an option in Draw.Text() to enable smooth fonts.
Text('foobar', 'normal', 1) # For smooth fonts
Any Comments, do we want this- should I use keyworkds.
static PyObject *Method_Text( PyObject * self, PyObject * args )
{
char *text;
char *font_str = NULL;
struct BMF_Font *font;
/* The following Variables are for international fonts (anti ailiased)*/
int international=0;
float raster_pos[4]; /* Get the glRasterPos and store here */
float scissor_box[4]; /* Used to offset the raster_pos */
if( !PyArg_ParseTuple( args, "s|si", &text, &font_str,
&international ) )
return EXPP_ReturnPyObjError( PyExc_TypeError,
"expected one or two string arguments with an
optional int" );
if( !font_str )
font = ( &G )->font;
else if( !strcmp( font_str, "large" ) )
font = BMF_GetFont(BMF_kScreen15);
else if( !strcmp( font_str, "normal" ) )
font = ( &G )->font;
else if( !strcmp( font_str, "small" ) )
font = ( &G )->fonts;
else if( !strcmp( font_str, "tiny" ) )
font = ( &G )->fontss;
else
return EXPP_ReturnPyObjError( PyExc_AttributeError,
"\"font\" must be: 'normal' (default),
'large', 'small', 'tiny'." );
if (international) {
/* True Type Fonts */
glGetFloatv(GL_CURRENT_RASTER_POSITION, raster_pos);
glGetFloatv(GL_SCISSOR_BOX, scissor_box);
ui_rasterpos_safe(raster_pos[0]-scissor_box[0],
raster_pos[1]-scissor_box[1], 1);
BIF_DrawString( font, text, 0);
return PyInt_FromLong( BMF_GetStringWidth( font, text ) ); /*
BIF_GetStringWidth causes OpenGL Errors! Why is this */
} else {
BMF_DrawString( font, text );
return PyInt_FromLong( BMF_GetStringWidth( font, text ) );
}
}
More information about the Bf-python
mailing list