本文整理汇总了C++中Font::GetCharacterBounds方法的典型用法代码示例。如果您正苦于以下问题:C++ Font::GetCharacterBounds方法的具体用法?C++ Font::GetCharacterBounds怎么用?C++ Font::GetCharacterBounds使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Font
的用法示例。
在下文中一共展示了Font::GetCharacterBounds方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: if
//
// DrawString
// Draws a string from an Font at position.
//
void Nixin::Canvas::DrawString( const Font& font, const Point& position, const std::string& text, const Colour& tint )
{
// Store the current position of the character on the screen.
Point currentPosition = position;
// For each character in the given string.
for( char character : text )
{
Rectangle characterBounds = font.GetCharacterBounds( character ); // Get the character bounds.
// If it's a space, we just increase the current position along the x axis.
if( character == ' ' )
{
currentPosition.x += font.GetSpacing().x;
currentPosition.x += font.GetCharacterPadding().x;
}
// If it's a new line, we reset the current x position, and decrease the y position by the font spacing.
else if( character == '\n' )
{
currentPosition.y -= characterBounds.height;
currentPosition.y -= font.GetSpacing().x;
currentPosition.y -= font.GetCharacterPadding().y;
currentPosition.x = position.x;
}
// If it's just a normal character, we draw it like any other sprite and add spacing and it's dimensions to the current width.
else
{
//spriteBuffer.BufferSprite( font.GetCharacterBitmap(), Rectangle( currentPosition, characterBounds.width, characterBounds.height ), Point( 1, 1 ), 0, tint, characterBounds, Point( 0, 0 ), false );
currentPosition.x += characterBounds.width;
currentPosition.x += font.GetCharacterPadding().x;
}
}
}