本文整理汇总了C++中TextRun::from方法的典型用法代码示例。如果您正苦于以下问题:C++ TextRun::from方法的具体用法?C++ TextRun::from怎么用?C++ TextRun::from使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类TextRun
的用法示例。
在下文中一共展示了TextRun::from方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: copyTextRunTo
void copyTextRunTo(const TextRun& run, UChar *word)
{
int word_size = run.length() - run.from(), j = 0;
for (int i = run.from(); i < run.length(); i++) {
if (Font::treatAsSpace(run[i])) {
word[j] = ' ';
j++;
} else {
word[j] = run[i];
j++;
}
}
word[j]='\0';
}
示例2: floatWidthForSimpleText
float Font::floatWidthForSimpleText(const TextRun& run, const TextStyle& style, float* startPosition, GlyphBuffer* glyphBuffer) const
{
int text_width;
// FIXME: Process normal, bold, italic styles
// if (m_fontDescription.italic()) {
// if (m_fontDescription.bold()) {
// // Bold && italic
// TTF_SetFontStyle(d->m_ttfFont, TTF_STYLE_BOLD | TTF_STYLE_ITALIC);
// } else {
// // Only italic
// TTF_SetFontStyle(d->m_ttfFont, TTF_STYLE_ITALIC);
// }
// } else if (m_fontDescription.bold()) {
// // Only bold
// TTF_SetFontStyle(d->m_ttfFont, TTF_STYLE_BOLD);
// } else
// TTF_SetFontStyle(d->m_ttfFont, TTF_STYLE_NORMAL);
int wordSize = run.length() - run.from();
UChar word[wordSize];
copyTextRunTo(run, word);
DFBCHECK(d->m_ttfFont->GetStringWidth(d->m_ttfFont, word, -1, &text_width));
if (startPosition) {
if (style.ltr())
*startPosition = text_width ;
else
*startPosition = text_width;
}
return static_cast<float> (text_width);
}
示例3: drawComplexText
void Font::drawComplexText(GraphicsContext* ctx, const TextRun& run, const TextStyle&, const FloatPoint& point) const
{
// FIXME: style, run.from()/length() cut-off
ctx->platformContext()->drawText(point,
QString::fromRawData(
reinterpret_cast<const QChar*>(
run.characters() + run.from()), run.length()));
}
示例4: drawSimpleText
/* SDL ttf implementation may be lighter ??? */
void Font::drawSimpleText(BIGraphicsContext* context, const TextRun& run, const TextStyle& style, const FloatPoint& point) const
{
WebCore::Color color = context->strokeColor();
BCNativeImage* text_surface = static_cast<BCNativeImage*>(context->getNativeImage())->getSurface();
// FIXME: Process normal, bold, italic styles
// if (m_fontDescription.italic())
// {
// if (m_fontDescription.bold())
// { // Bold && italic
// TTF_SetFontStyle(d->m_ttfFont, TTF_STYLE_BOLD | TTF_STYLE_ITALIC);
// }
// else
// { // Only italic
// TTF_SetFontStyle(d->m_ttfFont, TTF_STYLE_ITALIC);
// }
// }
// else if (m_fontDescription.bold())
// { // Only bold
// TTF_SetFontStyle(d->m_ttfFont, TTF_STYLE_BOLD);
// }
// else
// {
// TTF_SetFontStyle(d->m_ttfFont, TTF_STYLE_NORMAL);
// }
DFBCHECK(text_surface->SetFont(text_surface, d->m_ttfFont));
// Set font color
DFBCHECK(text_surface->SetColor(text_surface, color.red(), color.green(), color.blue(), color.alpha()));
// Draw font
int wordSize = run.length() - run.from();
UChar word[wordSize];
copyTextRunTo(run, word);
DFBCHECK(text_surface->DrawString(text_surface, word, -1, point.x(), point.y(), DSTF_TOP | DSTF_LEFT));
}
示例5: floatWidthForComplexText
float Font::floatWidthForComplexText(const TextRun& run, const TextStyle&) const
{
// FIXME: style
QFontMetricsF metrics(primaryFont()->m_font.font());
return metrics.width(QString::fromRawData(reinterpret_cast<const QChar*>(run.characters() + run.from()), run.length()));
}
示例6: offsetForPositionForSimpleText
int Font::offsetForPositionForSimpleText(const TextRun& run, const TextStyle& style, int x, bool includePartialGlyphs) const
{
return run.to() - run.from();
}