本文整理汇总了C++中QTextFragment::glyphRuns方法的典型用法代码示例。如果您正苦于以下问题:C++ QTextFragment::glyphRuns方法的具体用法?C++ QTextFragment::glyphRuns怎么用?C++ QTextFragment::glyphRuns使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类QTextFragment
的用法示例。
在下文中一共展示了QTextFragment::glyphRuns方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: addTextBlock
void QSGTextNode::addTextBlock(const QPointF &position, QTextDocument *textDocument, const QTextBlock &block,
const QColor &overrideColor, QSGText::TextStyle style, const QColor &styleColor)
{
if (!block.isValid())
return;
QPointF blockPosition = textDocument->documentLayout()->blockBoundingRect(block).topLeft();
QTextBlock::iterator it = block.begin();
while (!it.atEnd()) {
QTextFragment fragment = it.fragment();
if (!fragment.text().isEmpty()) {
QTextCharFormat charFormat = fragment.charFormat();
QColor color = overrideColor.isValid()
? overrideColor
: charFormat.foreground().color();
QList<QGlyphRun> glyphsList = fragment.glyphRuns();
for (int i=0; i<glyphsList.size(); ++i) {
QGlyphRun glyphs = glyphsList.at(i);
QRawFont font = glyphs.rawFont();
QSGGlyphNode *glyphNode = addGlyphs(position + blockPosition + QPointF(0, font.ascent()),
glyphs, color, style, styleColor);
int decorations = (glyphs.overline() ? Overline : 0) |
(glyphs.strikeOut() ? StrikeOut : 0) |
(glyphs.underline() ? Underline : 0);
if (decorations) {
QPointF baseLine = glyphNode->baseLine();
qreal width = glyphNode->boundingRect().width();
addTextDecorations(Decoration(decorations), baseLine, color, width,
font.lineThickness(), font.underlinePosition(), font.ascent());
}
}
}
++it;
}
}