本文整理汇总了C++中LPD3DXFONT::SetIndex方法的典型用法代码示例。如果您正苦于以下问题:C++ LPD3DXFONT::SetIndex方法的具体用法?C++ LPD3DXFONT::SetIndex怎么用?C++ LPD3DXFONT::SetIndex使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类LPD3DXFONT
的用法示例。
在下文中一共展示了LPD3DXFONT::SetIndex方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: DrawText
//.........这里部分代码省略.........
float scale2 = fsize / (rct->bottom - rct->top);
fwidth += ((rct->right - rct->left - BFONTSPACEW) * scale2) * scale;
fheight = ((rct->bottom - rct->top) * scale2) * scale;
}
}
if(style&FONT_STYLE_MULTILINE)
{
rect.left -= BFONTSPACE;
rect.right -= BFONTSPACE;
}
else
{
if(style&FONT_STYLE_CENTERALIGN)
{
float hfwidth = fwidth / 2.0f;
float hwidth = (rect.right - rect.left) / 2.0f;
rect.left = (rect.left + hwidth) - hfwidth - BFONTSPACEW;
rect.right = rect.left + fwidth - BFONTSPACEW;
}
else if(style&FONT_STYLE_RIGHTALIGN)
{
rect.left = rect.right - fwidth - BFONTSPACE;
rect.right = rect.left + fwidth - BFONTSPACE;
}
else
{
rect.left -= BFONTSPACE;
rect.right = rect.left + fwidth - BFONTSPACE;
}
if(style&FONT_STYLE_VCENTERALIGN)
{
float hfheight = fheight / 2.0f;
float hheight = (rect.bottom - rect.top) / 2.0f;
rect.top = (rect.top + hheight) - hfheight;
rect.bottom = rect.top + fheight;
}
else if(style&FONT_STYLE_BOTTOMALIGN)
{
rect.top = rect.bottom - fheight;
rect.right = rect.top + fheight;
}
else
{
rect.bottom = rect.top + fheight;
}
}
float ty = 0.0f;
float tx = 0;
for(unsigned int i=0; i<txtsize; i++)
{
rct = Font->GetSpriteRect((unsigned int)text[i]);
if(rct!=0)
{
float scale2 = fsize / (rct->bottom - rct->top);
if(style&FONT_STYLE_MULTILINE)
{
RectangleF rect2 = rect;
rect2.left = rect.left + tx;
rect2.right = (rect2.left + (rct->right - rct->left) * scale2 * scale);
if(rect2.right>rect.right || text[i] == L'\n' || text[i] == L'\r')
{
ty += fsize * scale + BFONTVSPACE;
tx = 0;
rect2.left = rect.left + tx;
rect2.right = (rect2.left + (rct->right - rct->left) * scale2 * scale);
}
rect2.top = rect.top + ty;
rect2.bottom = (rect2.top + fsize * scale);
if(!(text[i] == L'\n' || text[i] == L'\r'))
{
Font->SetIndex((unsigned int)text[i]);
if(Drawonly==-1 || Drawonly==i) Font->Draw(this, rect2, color, 0.0f, 0.0f);
tx += ((rct->right - rct->left - BFONTSPACEW) * scale2) * scale;
}
}
else
{
rect.right = (rect.left + (rct->right - rct->left) * scale2 * scale);
rect.bottom = (rect.top + fsize * scale);
Font->SetIndex((unsigned int)text[i]);
if(Drawonly==-1 || Drawonly==i) Font->Draw(this, rect, color, 0.0f, 0.0f);
rect.left += ((rct->right - rct->left - BFONTSPACEW) * scale2) * scale;
}
}
}
#else
Font->DrawTextW(m_sprite, text, -1, (LPRECT)&rect, style, color);
m_sprite->SetTransform(&m2);
#endif
}