本文整理汇总了C++中vecText::end方法的典型用法代码示例。如果您正苦于以下问题:C++ vecText::end方法的具体用法?C++ vecText::end怎么用?C++ vecText::end使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类vecText
的用法示例。
在下文中一共展示了vecText::end方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: LineBreakText
void CGUITextLayout::LineBreakText(const vecText &text, vector<CGUIString> &lines)
{
int nMaxLines = (m_maxHeight > 0 && m_font && m_font->GetLineHeight() > 0)?(int)ceilf(m_maxHeight / m_font->GetLineHeight()):-1;
vecText::const_iterator lineStart = text.begin();
vecText::const_iterator pos = text.begin();
while (pos != text.end() && (nMaxLines <= 0 || lines.size() < (size_t)nMaxLines))
{
// Get the current letter in the string
character_t letter = *pos;
// Handle the newline character
if ((letter & 0xffff) == L'\n' )
{ // push back everything up till now
CGUIString string(lineStart, pos, true);
lines.push_back(string);
lineStart = pos + 1;
}
pos++;
}
// handle the last line if non-empty
if (lineStart < text.end() && (nMaxLines <= 0 || lines.size() < (size_t)nMaxLines))
{
CGUIString string(lineStart, text.end(), true);
lines.push_back(string);
}
}
示例2: LineBreakText
void CGUITextLayout::LineBreakText(const vecText &text, vector<CGUIString> &lines)
{
bool bUseHeight = (m_maxHeight > 0 && m_font && m_font->GetLineHeight() > 0);
int nMaxLines = bUseHeight?(int)(m_maxHeight / m_font->GetLineHeight()):-1;
if (bUseHeight && nMaxLines == 0) // hack. if height is not enough - force 1 line of text
nMaxLines = 1;
vecText::const_iterator lineStart = text.begin();
vecText::const_iterator pos = text.begin();
while (pos != text.end() && (nMaxLines <= 0 || lines.size() < (size_t)nMaxLines))
{
// Get the current letter in the string
character_t letter = *pos;
// Handle the newline character
if ((letter & 0xffff) == L'\n' )
{ // push back everything up till now
CGUIString string(lineStart, pos, true);
lines.push_back(string);
lineStart = pos + 1;
}
pos++;
}
}
示例3: DrawTextInternal
void CGUIFontTTFBase::DrawTextInternal(float x, float y, const vecColors &colors, const vecText &text, uint32_t alignment, float maxPixelWidth, bool scrolling)
{
Begin();
// save the origin, which is scaled separately
m_originX = x;
m_originY = y;
// Check if we will really need to truncate or justify the text
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 : 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 + 0.5f ) // + 0.5f due to rounding issues
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 ( 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);
}
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 )
{
// Check if we will be exceeded the max allowed width
if ( cursorX + ch->advance + 3 * m_ellipsesWidth > maxPixelWidth )
{
// Yup. Let's draw the ellipses, then bail
// Perhaps we should really bail to the next line in this case??
Character *period = GetCharacter(L'.');
if (!period)
break;
for (int i = 0; i < 3; i++)
{
RenderCharacter(startX + cursorX, startY, period, color, !scrolling);
cursorX += period->advance;
}
break;
}
}
else if (maxPixelWidth > 0 && cursorX > maxPixelWidth)
break; // exceeded max allowed width - stop rendering
RenderCharacter(startX + cursorX, startY, ch, color, !scrolling);
if ( alignment & XBFONT_JUSTIFIED )
{
if ((*pos & 0xffff) == L' ')
cursorX += ch->advance + spacePerLetter * justification_word_weight;
else
cursorX += ch->advance + spacePerLetter;
//.........这里部分代码省略.........
示例4: DrawTextInternal
void CGUIFontTTFBase::DrawTextInternal(float x, float y, const vecColors &colors, const vecText &text, uint32_t alignment, float maxPixelWidth, bool scrolling)
{
Begin();
uint32_t rawAlignment = alignment;
bool dirtyCache;
bool hardwareClipping = g_Windowing.ScissorsCanEffectClipping();
CGUIFontCacheStaticPosition staticPos(x, y);
CGUIFontCacheDynamicPosition dynamicPos;
if (hardwareClipping)
{
dynamicPos = CGUIFontCacheDynamicPosition(g_graphicsContext.ScaleFinalXCoord(x, y),
g_graphicsContext.ScaleFinalYCoord(x, y),
g_graphicsContext.ScaleFinalZCoord(x, y));
}
CVertexBuffer unusedVertexBuffer;
CVertexBuffer &vertexBuffer = hardwareClipping ?
m_dynamicCache.Lookup(dynamicPos,
colors, text,
alignment, maxPixelWidth,
scrolling,
XbmcThreads::SystemClockMillis(),
dirtyCache) :
unusedVertexBuffer;
std::shared_ptr<std::vector<SVertex> > tempVertices = std::make_shared<std::vector<SVertex> >();
std::shared_ptr<std::vector<SVertex> > &vertices = hardwareClipping ?
tempVertices :
static_cast<std::shared_ptr<std::vector<SVertex> >&>(m_staticCache.Lookup(staticPos,
colors, text,
alignment, maxPixelWidth,
scrolling,
XbmcThreads::SystemClockMillis(),
dirtyCache));
if (dirtyCache)
{
// save the origin, which is scaled separately
m_originX = x;
m_originY = y;
// Check if we will really need to truncate or justify the text
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 : 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 + 0.5f ) // + 0.5f due to rounding issues
w = maxPixelWidth;
if ( alignment & XBFONT_CENTER_X)
w *= 0.5f;
// Offset this line's starting position
startX -= w;
}
float spacePerSpaceCharacter = 0; // for justification effects
if ( alignment & XBFONT_JUSTIFIED )
{
// first compute the size of the text to render in both characters and pixels
unsigned int numSpaces = 0;
float linePixels = 0;
for (vecText::const_iterator pos = text.begin(); pos != text.end(); ++pos)
{
Character *ch = GetCharacter(*pos);
if (ch)
{
if ((*pos & 0xffff) == L' ')
numSpaces += 1;
linePixels += ch->advance;
}
}
if (numSpaces > 0)
spacePerSpaceCharacter = (maxPixelWidth - linePixels) / numSpaces;
}
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
//.........这里部分代码省略.........
示例5: GetTextWidth
float CGUIFont::GetTextWidth( const vecText &text )
{
if (!m_font) return 0;
CSingleLock lock(g_graphicsContext);
return m_font->GetTextWidthInternal(text.begin(), text.end()) * g_graphicsContext.GetGUIScaleX();
}
示例6: 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 )
//.........这里部分代码省略.........