本文整理汇总了C++中UTF8::uend方法的典型用法代码示例。如果您正苦于以下问题:C++ UTF8::uend方法的具体用法?C++ UTF8::uend怎么用?C++ UTF8::uend使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类UTF8
的用法示例。
在下文中一共展示了UTF8::uend方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: computeTextSize
VECTOR2D STROKE_FONT::computeTextSize( const UTF8& aText ) const
{
VECTOR2D result = VECTOR2D( 0.0, m_glyphSize.y );
for( UTF8::uni_iter it = aText.ubegin(), end = aText.uend(); it < end; ++it )
{
wxASSERT_MSG( *it != '\n',
wxT( "This function is intended to work with single line strings" ) );
// If it is double tilda, then it is displayed as a single tilda
// If it is single tilda, then it is toggling overbar, so we need to skip it
if( *it == '~' )
{
if( ++it >= end )
break;
}
// Index in the bounding boxes table
int dd = *it - ' ';
if( dd >= (int) m_glyphBoundingBoxes.size() || dd < 0 )
dd = '?' - ' ';
result.x += m_glyphSize.x * m_glyphBoundingBoxes[dd].GetEnd().x;
}
return result;
}
示例2: ComputeStringBoundaryLimits
VECTOR2D STROKE_FONT::ComputeStringBoundaryLimits( const UTF8& aText, VECTOR2D aGlyphSize,
double aGlyphThickness,
double* aTopLimit, double* aBottomLimit ) const
{
VECTOR2D string_bbox;
double ymax = 0.0;
double ymin = 0.0;
for( UTF8::uni_iter it = aText.ubegin(), end = aText.uend(); it < end; ++it )
{
wxASSERT_MSG( *it != '\n',
wxT( "This function is intended to work with single line strings" ) );
// If it is double tilda, then it is displayed as a single tilda
// If it is single tilda, then it is toggling overbar, so we need to skip it
if( *it == '~' )
{
if( ++it >= end )
break;
}
// Index in the bounding boxes table
int dd = *it - ' ';
if( dd >= (int) m_glyphBoundingBoxes.size() || dd < 0 )
dd = '?' - ' ';
const BOX2D& box = m_glyphBoundingBoxes[dd];
string_bbox.x += box.GetEnd().x;
// Calculate Y min and Y max
if( aTopLimit )
{
ymax = std::max( ymax, box.GetY() );
ymax = std::max( ymax, box.GetEnd().y );
}
if( aBottomLimit )
{
ymin = std::min( ymin, box.GetY() );
ymin = std::min( ymin, box.GetEnd().y );
}
}
string_bbox.x *= aGlyphSize.x;
string_bbox.x += aGlyphThickness;
string_bbox.y = aGlyphSize.y + aGlyphThickness;
// For italic correction, take in account italic tilt
if( m_gal->IsFontItalic() )
string_bbox.x += string_bbox.y * STROKE_FONT::ITALIC_TILT;
if( aTopLimit )
*aTopLimit = ymax * aGlyphSize.y;
if( aBottomLimit )
*aBottomLimit = ymin * aGlyphSize.y;
return string_bbox;
}
示例3: drawSingleLineText
void STROKE_FONT::drawSingleLineText( const UTF8& aText )
{
// By default the overbar is turned off
bool overbar = false;
double xOffset;
VECTOR2D glyphSize( m_gal->GetGlyphSize() );
double overbar_italic_comp = computeOverbarVerticalPosition() * ITALIC_TILT;
if( m_gal->IsTextMirrored() )
overbar_italic_comp = -overbar_italic_comp;
// Compute the text size
VECTOR2D textSize = computeTextLineSize( aText );
double half_thickness = m_gal->GetLineWidth()/2;
// Context needs to be saved before any transformations
m_gal->Save();
// First adjust: the text X position is corrected by half_thickness
// because when the text with thickness is draw, its full size is textSize,
// but the position of lines is half_thickness to textSize - half_thickness
// so we must translate the coordinates by half_thickness on the X axis
// to place the text inside the 0 to textSize X area.
m_gal->Translate( VECTOR2D( half_thickness, 0 ) );
// Adjust the text position to the given horizontal justification
switch( m_gal->GetHorizontalJustify() )
{
case GR_TEXT_HJUSTIFY_CENTER:
m_gal->Translate( VECTOR2D( -textSize.x / 2.0, 0 ) );
break;
case GR_TEXT_HJUSTIFY_RIGHT:
if( !m_gal->IsTextMirrored() )
m_gal->Translate( VECTOR2D( -textSize.x, 0 ) );
break;
case GR_TEXT_HJUSTIFY_LEFT:
if( m_gal->IsTextMirrored() )
m_gal->Translate( VECTOR2D( -textSize.x, 0 ) );
break;
default:
break;
}
if( m_gal->IsTextMirrored() )
{
// In case of mirrored text invert the X scale of points and their X direction
// (m_glyphSize.x) and start drawing from the position where text normally should end
// (textSize.x)
xOffset = textSize.x - m_gal->GetLineWidth();
glyphSize.x = -glyphSize.x;
}
else
{
xOffset = 0.0;
}
// The overbar is indented inward at the beginning of an italicized section, but
// must not be indented on subsequent letters to ensure that the bar segments
// overlap.
bool last_had_overbar = false;
for( UTF8::uni_iter chIt = aText.ubegin(), end = aText.uend(); chIt < end; ++chIt )
{
// Toggle overbar
if( *chIt == '~' )
{
if( ++chIt >= end )
break;
if( *chIt != '~' ) // It was a single tilda, it toggles overbar
overbar = !overbar;
// If it is a double tilda, just process the second one
}
int dd = *chIt - ' ';
if( dd >= (int) m_glyphBoundingBoxes.size() || dd < 0 )
dd = '?' - ' ';
GLYPH& glyph = m_glyphs[dd];
BOX2D& bbox = m_glyphBoundingBoxes[dd];
if( overbar )
{
double overbar_start_x = xOffset;
double overbar_start_y = - computeOverbarVerticalPosition();
double overbar_end_x = xOffset + glyphSize.x * bbox.GetEnd().x;
double overbar_end_y = overbar_start_y;
if( !last_had_overbar )
{
overbar_start_x += overbar_italic_comp;
last_had_overbar = true;
}
//.........这里部分代码省略.........
示例4: drawSingleLineText
void STROKE_FONT::drawSingleLineText( const UTF8& aText )
{
// By default the overbar is turned off
m_overbar = false;
double xOffset;
VECTOR2D glyphSize( m_glyphSize );
// Compute the text size
VECTOR2D textSize = computeTextSize( aText );
m_gal->Save();
// Adjust the text position to the given alignment
switch( m_horizontalJustify )
{
case GR_TEXT_HJUSTIFY_CENTER:
m_gal->Translate( VECTOR2D( -textSize.x / 2.0, 0 ) );
break;
case GR_TEXT_HJUSTIFY_RIGHT:
if( !m_mirrored )
m_gal->Translate( VECTOR2D( -textSize.x, 0 ) );
break;
case GR_TEXT_HJUSTIFY_LEFT:
if( m_mirrored )
m_gal->Translate( VECTOR2D( -textSize.x, 0 ) );
break;
default:
break;
}
if( m_mirrored )
{
// In case of mirrored text invert the X scale of points and their X direction
// (m_glyphSize.x) and start drawing from the position where text normally should end
// (textSize.x)
xOffset = textSize.x;
glyphSize.x = -m_glyphSize.x;
}
else
{
xOffset = 0.0;
}
for( UTF8::uni_iter chIt = aText.ubegin(), end = aText.uend(); chIt < end; ++chIt )
{
// Toggle overbar
if( *chIt == '~' )
{
if( ++chIt >= end )
break;
if( *chIt != '~' ) // It was a single tilda, it toggles overbar
m_overbar = !m_overbar;
// If it is a double tilda, just process the second one
}
int dd = *chIt - ' ';
if( dd >= (int) m_glyphBoundingBoxes.size() || dd < 0 )
dd = '?' - ' ';
GLYPH& glyph = m_glyphs[dd];
BOX2D& bbox = m_glyphBoundingBoxes[dd];
if( m_overbar )
{
VECTOR2D startOverbar( xOffset, -getInterline() * OVERBAR_HEIGHT );
VECTOR2D endOverbar( xOffset + glyphSize.x * bbox.GetEnd().x,
-getInterline() * OVERBAR_HEIGHT );
m_gal->DrawLine( startOverbar, endOverbar );
}
for( GLYPH::iterator pointListIt = glyph.begin(); pointListIt != glyph.end();
++pointListIt )
{
std::deque<VECTOR2D> pointListScaled;
for( std::deque<VECTOR2D>::iterator pointIt = pointListIt->begin();
pointIt != pointListIt->end(); ++pointIt )
{
VECTOR2D pointPos( pointIt->x * glyphSize.x + xOffset, pointIt->y * glyphSize.y );
if( m_italic )
{
// FIXME should be done other way - referring to the lowest Y value of point
// because now italic fonts are translated a bit
if( m_mirrored )
pointPos.x += pointPos.y * 0.1;
else
pointPos.x -= pointPos.y * 0.1;
}
pointListScaled.push_back( pointPos );
}
//.........这里部分代码省略.........