//=============== //SCR_DrawStringWidth - clamp to width in pixels. Returns drawn len //=============== int SCR_DrawStringWidth( int x, int y, int align, const char *str, int maxwidth, struct mufont_s *font, vec4_t color ) { int width; if( !str ) return 0; if( !font ) font = cls.fontSystemSmall; if( maxwidth < 0 ) maxwidth = 0; width = SCR_strWidth( str, font, 0 ); if( width ) { if( maxwidth && width > maxwidth ) width = maxwidth; x = SCR_HorizontalAlignForString( x, align, width ); y = SCR_VerticalAlignForString( y, align, font->fontheight ); return SCR_DrawRawString( x, y, str, maxwidth, font, color ); } return 0; }
//================== // SCR_DrawString //================== void SCR_DrawString( int x, int y, int align, const char *str, struct mufont_s *font, vec4_t color ) { int width; if( !str ) return; if( !font ) font = cls.fontSystemSmall; width = SCR_strWidth( str, font, 0 ); if( width ) { x = SCR_HorizontalAlignForString( x, align, width ); y = SCR_VerticalAlignForString( y, align, font->fontheight ); if( y <= -font->fontheight || y >= (int)viddef.height ) return; // totally off screen if( x <= -width || x >= (int)viddef.width ) return; // totally off screen SCR_DrawRawString( x, y, str, 0, font, color ); } }
/* * 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 ); } }
/* * 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; }
/* * 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; }