本文整理汇总了C++中reference::GetFontDescription方法的典型用法代码示例。如果您正苦于以下问题:C++ reference::GetFontDescription方法的具体用法?C++ reference::GetFontDescription怎么用?C++ reference::GetFontDescription使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类reference
的用法示例。
在下文中一共展示了reference::GetFontDescription方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: RenderString
void StringPrinter::RenderString(const reference<BitmapFont>& bitmapFont,
const char* szPrintableString, int maxLength,
int positionX,
int positionY,
int clipWidth,
int clipHeight, eUiTextColor color)
{
assert(bitmapFont);
if (!bitmapFont || !szPrintableString || maxLength == 0 || clipWidth == 0 || clipHeight == 0)
{
return;
}
// setup palette
if (mCurrentTextColor != color)
{
mCurrentTextColor = color;
GfxRenderDevice::Instance().SetPaletteEntries(gUiTextColorsRGB[mCurrentTextColor], NUM_UI_TEXT_COLOR_ENTRIES, 0, GFX_PALETTE_UI);
}
const BitmapFontDescription& bmpf = bitmapFont->GetFontDescription();
// tiles buffer
GfxTile batchQuads[256];
// process characters
for (int iquad = 0, currentBoxWidth = 0, currentBoxHeight = 0, ichar = 0;; ++ichar)
{
if (szPrintableString[ichar] == 0 || (maxLength > 0 && ichar == maxLength))
{
if (iquad > 0)
{
mRenderDevice.RenderTilesBatch(bmpf.fontTexture, batchQuads, iquad);
}
break;
}
const BitmapFontCharacter& bmpc = bitmapFont->GetCharacter(szPrintableString[ichar]);
if (bmpc.height == 0 || bmpc.width == 0)
{
continue;
}
bool shouldEnd =
((clipWidth > 0) && (currentBoxWidth + bmpc.width + bmpc.xadvance > clipWidth)) ||
((clipHeight > 0) && (currentBoxHeight + bmpc.height > clipHeight));
if (shouldEnd)
{
maxLength = ichar + 1;
continue;
}
currentBoxWidth += bmpc.width + bmpc.xadvance;
currentBoxHeight += bmpc.height;
batchQuads[iquad].destination = { positionX, positionY, 128 };
batchQuads[iquad].rcSource = { bmpc.xoffset, bmpc.yoffset, bmpc.width, bmpc.height };
batchQuads[iquad].params = {};
batchQuads[iquad].params.paletteIndex = GFX_PALETTE_UI;
positionX += bmpc.width + bmpc.xadvance;
if (++iquad == sizeof(batchQuads))
{
mRenderDevice.RenderTilesBatch(bmpf.fontTexture, batchQuads, iquad);
iquad = 0;
}
}
}