本文整理汇总了C++中vecText::size方法的典型用法代码示例。如果您正苦于以下问题:C++ vecText::size方法的具体用法?C++ vecText::size怎么用?C++ vecText::size使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类vecText
的用法示例。
在下文中一共展示了vecText::size方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1:
void CGUITextLayout::AppendToUTF32(const CStdStringW &utf16, character_t colStyle, vecText &utf32)
{
// NOTE: Assumes a single line of text
utf32.reserve(utf32.size() + utf16.size());
for (unsigned int i = 0; i < utf16.size(); i++)
utf32.push_back(utf16[i] | colStyle);
}
示例2: DrawScrollingText
void CGUIFont::DrawScrollingText(float x, float y, const vecColors &colors, color_t shadowColor,
const vecText &text, uint32_t alignment, float maxWidth, const CScrollInfo &scrollInfo)
{
if (!m_font) return;
if (!shadowColor) shadowColor = m_shadowColor;
if (!text.size() || ClippedRegionIsEmpty(x, y, maxWidth, alignment))
return; // nothing to render
if (!scrollInfo.m_widthValid)
{
/* Calculate the pixel width of the complete string */
scrollInfo.m_textWidth = GetTextWidth(text);
scrollInfo.m_totalWidth = scrollInfo.m_textWidth + GetTextWidth(scrollInfo.suffix);
scrollInfo.m_widthValid = true;
}
assert(scrollInfo.m_totalWidth != 0);
float textPixelWidth = ROUND(scrollInfo.m_textWidth / g_graphicsContext.GetGUIScaleX());
float suffixPixelWidth = ROUND((scrollInfo.m_totalWidth - scrollInfo.m_textWidth) / g_graphicsContext.GetGUIScaleX());
float offset;
if(scrollInfo.pixelSpeed >= 0)
offset = scrollInfo.pixelPos;
else
offset = scrollInfo.m_totalWidth - scrollInfo.pixelPos;
vecColors renderColors;
for (unsigned int i = 0; i < colors.size(); i++)
renderColors.push_back(g_graphicsContext.MergeAlpha(colors[i] ? colors[i] : m_textColor));
bool scroll = !scrollInfo.waitTime && scrollInfo.pixelSpeed;
if (shadowColor)
{
shadowColor = g_graphicsContext.MergeAlpha(shadowColor);
vecColors shadowColors;
for (unsigned int i = 0; i < renderColors.size(); i++)
shadowColors.push_back((renderColors[i] & 0xff000000) != 0 ? shadowColor : 0);
for (float dx = -offset; dx < maxWidth; dx += scrollInfo.m_totalWidth)
{
m_font->DrawTextInternal(x + dx + 1, y + 1, shadowColors, text, alignment, textPixelWidth, scroll);
m_font->DrawTextInternal(x + dx + scrollInfo.m_textWidth + 1, y + 1, shadowColors, scrollInfo.suffix, alignment, suffixPixelWidth, scroll);
}
}
for (float dx = -offset; dx < maxWidth; dx += scrollInfo.m_totalWidth)
{
m_font->DrawTextInternal(x + dx, y, renderColors, text, alignment, textPixelWidth, scroll);
m_font->DrawTextInternal(x + dx + scrollInfo.m_textWidth, y, renderColors, scrollInfo.suffix, alignment, suffixPixelWidth, scroll);
}
g_graphicsContext.RestoreClipRegion();
}
示例3: BuildTextCoordinates
void CGUIFontTTFBase::BuildTextCoordinates(float x, float y, const vecColors &colors, color_t shadowColor,
const vecText &text, uint32_t alignment, float maxPixelWidth, bool scrolling, FontCoordsIndiced& pData)
{
// Check if we will really need to truncate or justify the text
m_originX = x;
m_originY = y;
if ( alignment & XBFONT_TRUNCATED )
{
if ( maxPixelWidth <= 0.0f || GetTextWidthInternal(text.begin(), text.end()) <= maxPixelWidth)
alignment &= ~XBFONT_TRUNCATED;
}
else if ( alignment & XBFONT_JUSTIFIED )
{
if ( maxPixelWidth <= 0.0f )
alignment &= ~XBFONT_JUSTIFIED;
}
// calculate sizing information
float startX = 0;
float startY = (alignment & XBFONT_CENTER_Y) ? -0.5f*(m_cellHeight-2) : 0; // vertical centering
if ( alignment & (XBFONT_RIGHT | XBFONT_CENTER_X) )
{
// Get the extent of this line
float w = GetTextWidthInternal( text.begin(), text.end() );
if ( alignment & XBFONT_TRUNCATED && w > maxPixelWidth )
w = maxPixelWidth;
if ( alignment & XBFONT_CENTER_X)
w *= 0.5f;
// Offset this line's starting position
startX -= w;
}
float spacePerLetter = 0; // for justification effects
#if 0
if ( alignment & XBFONT_JUSTIFIED )
{
// first compute the size of the text to render in both characters and pixels
unsigned int lineChars = 0;
float linePixels = 0;
for (vecText::const_iterator pos = text.begin(); pos != text.end(); pos++)
{
Character *ch = GetCharacter(*pos);
if (ch)
{ // spaces have multiple times the justification spacing of normal letters
lineChars += ((*pos & 0xffff) == L' ') ? justification_word_weight : 1;
linePixels += ch->advance;
}
}
if (lineChars > 1)
spacePerLetter = (maxPixelWidth - linePixels) / (lineChars - 1);
}
#endif
ReloadFace();
#ifdef HAS_HARFBUZZ_NG
int i = 0;
wchar_t strW[text.size()];
for (vecText::const_iterator pos = text.begin(); pos != text.end(); pos++)
{
wchar_t letter = (wchar_t)((*pos) & 0xffff);
strW[i] = letter;
i++;
}
hb_buffer_t *hb_buffer = hb_buffer_create(text.size());
hb_buffer_set_unicode_funcs(hb_buffer, hb_glib_get_unicode_funcs());
hb_buffer_add_utf32(hb_buffer, (const uint32_t*) strW, text.size(), 0, text.size());
hb_buffer_set_direction(hb_buffer, HB_DIRECTION_LTR);
hb_shape (hb_font, hb_buffer, NULL, 0);
unsigned int glyph_info_len;
hb_glyph_info_t *hb_glyph = hb_buffer_get_glyph_infos (hb_buffer, &glyph_info_len);
hb_glyph_position_t *hb_position = hb_buffer_get_glyph_positions (hb_buffer, &glyph_info_len);
#else /* HAS_HARFBUZZ_NG */
FT_Vector delta;
Character* previousCh = NULL;
#endif
float cursorX = 0; // current position along the line
for (vecText::const_iterator pos = text.begin(); pos != text.end(); pos++)
{
// If starting text on a new line, determine justification effects
// Get the current letter in the CStdString
color_t color = (*pos & 0xff0000) >> 16;
if (color >= colors.size())
color = 0;
color = colors[color];
// grab the next character
Character *ch = GetCharacter(*pos);
if (!ch) continue;
if ( alignment & XBFONT_TRUNCATED )
//.........这里部分代码省略.........