当前位置: 首页>>代码示例>>C++>>正文


C++ Font::GetCharacterBounds方法代码示例

本文整理汇总了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;
		}
	}
}
开发者ID:Bonnn,项目名称:Nixin,代码行数:37,代码来源:Nixin_Canvas.cpp


注:本文中的Font::GetCharacterBounds方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。