本文整理汇总了C++中TextStyle::padding方法的典型用法代码示例。如果您正苦于以下问题:C++ TextStyle::padding方法的具体用法?C++ TextStyle::padding怎么用?C++ TextStyle::padding使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类TextStyle
的用法示例。
在下文中一共展示了TextStyle::padding方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: drawSimpleText
// SDL ttf implementation may be lighter ???
void Font::drawSimpleText(BIGraphicsContext* context, const TextRun& run, const TextStyle& style, const FloatPoint& point) const
{
WebCore::Color text_color = context->strokeColor();
BINativeImage* text_surface;
IntRect dst_rect;
IntPoint intPoint;
static int oldx = 0;
int text_width, text_height;
bool init = false;
int numSpaces = 0;
int padPerSpace = 0;
FloatPoint wordPoint(point);
// Process normal, bold, italic styles
if (m_fontDescription.italic()) {
if (m_fontDescription.bold()) {
// Bold && italic
d->m_ttfFont->style = FT_STYLE_BOLD | FT_STYLE_ITALIC;
d->flushCache(d->m_ttfFont);
} else {
// Only italic
d->m_ttfFont->style = FT_STYLE_ITALIC;
d->flushCache(d->m_ttfFont);
}
} else if (m_fontDescription.bold()) {
// Only bold
d->m_ttfFont->style = FT_STYLE_BOLD;
d->flushCache(d->m_ttfFont);
} else {
d->m_ttfFont->style = FT_STYLE_NORMAL;
d->flushCache(d->m_ttfFont);
}
// Draw font
int wordSize = run.length() - run.from();
UChar word[wordSize];
copyTextRunTo(run, word);
for (int i = 0; i <= wordSize; i++) {
if (Font::treatAsSpace(word[i]))
numSpaces++;;
}
if (numSpaces == 0)
padPerSpace = 0;
else
padPerSpace = static_cast<int> (ceil(style.padding() / numSpaces));
UChar text[wordSize + 1];
int j = 0;
for (int i = 0; i <= wordSize; i++) {
if (Font::treatAsSpace(word[i]) || i == wordSize) {
text[j] = ' ';
text[++j] = '\0';
d->sizeUnicode(d->m_ttfFont, text, &text_width, &text_height);
text_surface = d->renderUnicodeBlended(d->m_ttfFont, text, text_color, context->alphaLayer());
if (text_surface) {
intPoint.setX(static_cast<uint16_t> (wordPoint.x()));
intPoint.setY(static_cast<uint16_t> (wordPoint.y()) - ascent());
dst_rect.setX(0);
dst_rect.setY(0);
dst_rect.setWidth(text_surface->size().width());
dst_rect.setHeight(text_surface->size().height());
getBIGraphicsDevice()->copy(*(context->widget()), *text_surface, dst_rect, intPoint, context->alphaLayer());
delete text_surface;
}
wordPoint = wordPoint + FloatSize(padPerSpace + text_width,0);
j = 0;
} else {
text[j] = word[i];
j++;
}
}
}