コード例 #1
0
/*
* SCR_DrawString
*/
void SCR_DrawString( int x, int y, int align, const char *str, qfontface_t *font, vec4_t color )
{
	size_t width;
	int fontHeight;

	if( !str )
		return;

	if( !font )
		font = cls.fontSystemSmall;
	fontHeight = FTLIB_FontHeight( font );

	width = FTLIB_StringWidth( str, font, 0 );
	if( width )
	{
		x = SCR_HorizontalAlignForString( x, align, width );
		y = SCR_VerticalAlignForString( y, align, fontHeight );

		if( y <= -fontHeight || y >= (int)viddef.height )
			return; // totally off screen

		if( x + width <= 0 || x >= (int)viddef.width )
			return; // totally off screen

		FTLIB_DrawRawString( x, y, str, 0, font, color );
	}
}
コード例 #2
0
/*
* SCR_DrawStringWidth
*
* ClampS to width in pixels. Returns drawn len
*/
size_t SCR_DrawStringWidth( int x, int y, int align, const char *str, size_t maxwidth, qfontface_t *font, vec4_t color )
{
	size_t width;
	int fontHeight;

	if( !str )
		return 0;

	if( !font )
		font = cls.fontSystemSmall;
	fontHeight = FTLIB_FontHeight( font );

	if( maxwidth < 0 )
		maxwidth = 0;

	width = FTLIB_StringWidth( str, font, 0 );
	if( width )
	{
		if( maxwidth && width > maxwidth )
			width = maxwidth;

		x = SCR_HorizontalAlignForString( x, align, width );
		y = SCR_VerticalAlignForString( y, align, fontHeight );

		return FTLIB_DrawRawString( x, y, str, maxwidth, font, color );
	}

	return 0;
}
コード例 #3
0
ファイル: cl_screen.c プロジェクト: tenght/qfusion
/*
* SCR_DrawString
*/
int SCR_DrawString( int x, int y, int align, const char *str, qfontface_t *font, vec4_t color, int flags )
{
	int width;
	int fontHeight;

	if( !str )
		return 0;

	if( !font )
		font = cls.consoleFont;
	fontHeight = FTLIB_FontHeight( font );

	if( ( align % 3 ) != 0 ) // not left - don't precalculate the width if not needed
		x = SCR_HorizontalAlignForString( x, align, FTLIB_StringWidth( str, font, 0, flags ) );
	y = SCR_VerticalAlignForString( y, align, fontHeight );

	FTLIB_DrawRawString( x, y, str, 0, &width, font, color, flags );

	return width;
}