本文整理汇总了C++中QRawFont::lineThickness方法的典型用法代码示例。如果您正苦于以下问题:C++ QRawFont::lineThickness方法的具体用法?C++ QRawFont::lineThickness怎么用?C++ QRawFont::lineThickness使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类QRawFont
的用法示例。
在下文中一共展示了QRawFont::lineThickness方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: addTextLayout
void QSGTextNode::addTextLayout(const QPointF &position, QTextLayout *textLayout, const QColor &color,
QSGText::TextStyle style, const QColor &styleColor)
{
QList<QGlyphRun> glyphsList(textLayout->glyphRuns());
QSGGlyphNode *prevNode = 0;
QFont font = textLayout->font();
qreal underlinePosition, ascent, lineThickness;
int decorations = NoDecoration;
decorations |= (font.underline() ? Underline : 0);
decorations |= (font.overline() ? Overline : 0);
decorations |= (font.strikeOut() ? StrikeOut : 0);
underlinePosition = ascent = lineThickness = 0;
for (int i=0; i<glyphsList.size(); ++i) {
QGlyphRun glyphs = glyphsList.at(i);
QRawFont rawfont = glyphs.rawFont();
prevNode = addGlyphs(position + QPointF(0, rawfont.ascent()), glyphs, color, style, styleColor);
if (decorations) {
qreal rawAscent = rawfont.ascent();
if (decorations & Underline) {
ascent = qMax(ascent, rawAscent);
qreal pos = rawfont.underlinePosition();
if (pos > underlinePosition) {
underlinePosition = pos;
// take line thickness from the rawfont with maximum underline
// position in this case
lineThickness = rawfont.lineThickness();
}
} else {
// otherwise it's strike out or overline, we take line thickness
// from the rawfont with maximum ascent
if (rawAscent > ascent) {
ascent = rawAscent;
lineThickness = rawfont.lineThickness();
}
}
}
}
if (decorations) {
addTextDecorations(Decoration(decorations), position + QPointF(0, ascent), color,
textLayout->boundingRect().width(),
lineThickness, underlinePosition, ascent);
}
}
示例2: 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;
}
}
示例3: processCurrentLine
void QQuickTextNodeEngine::processCurrentLine()
{
// No glyphs, do nothing
if (m_currentLineTree.isEmpty())
return;
// 1. Go through current line and get correct decoration position for each node based on
// neighbouring decorations. Add decoration to global list
// 2. Create clip nodes for all selected text. Try to merge as many as possible within
// the line.
// 3. Add QRects to a list of selection rects.
// 4. Add all nodes to a global processed list
QVarLengthArray<int> sortedIndexes; // Indexes in tree sorted by x position
BinaryTreeNode::inOrder(m_currentLineTree, &sortedIndexes);
Q_ASSERT(sortedIndexes.size() == m_currentLineTree.size());
SelectionState currentSelectionState = Unselected;
QRectF currentRect;
QQuickTextNode::Decorations currentDecorations = QQuickTextNode::NoDecoration;
qreal underlineOffset = 0.0;
qreal underlineThickness = 0.0;
qreal overlineOffset = 0.0;
qreal overlineThickness = 0.0;
qreal strikeOutOffset = 0.0;
qreal strikeOutThickness = 0.0;
QRectF decorationRect = currentRect;
QColor lastColor;
QColor lastBackgroundColor;
QVarLengthArray<TextDecoration> pendingUnderlines;
QVarLengthArray<TextDecoration> pendingOverlines;
QVarLengthArray<TextDecoration> pendingStrikeOuts;
if (!sortedIndexes.isEmpty()) {
QQuickDefaultClipNode *currentClipNode = m_hasSelection ? new QQuickDefaultClipNode(QRectF()) : 0;
bool currentClipNodeUsed = false;
for (int i=0; i<=sortedIndexes.size(); ++i) {
BinaryTreeNode *node = 0;
if (i < sortedIndexes.size()) {
int sortedIndex = sortedIndexes.at(i);
Q_ASSERT(sortedIndex < m_currentLineTree.size());
node = m_currentLineTree.data() + sortedIndex;
}
if (i == 0)
currentSelectionState = node->selectionState;
// Update decorations
if (currentDecorations != QQuickTextNode::NoDecoration) {
decorationRect.setY(m_position.y() + m_currentLine.y());
decorationRect.setHeight(m_currentLine.height());
if (node != 0)
decorationRect.setRight(node->boundingRect.left());
TextDecoration textDecoration(currentSelectionState, decorationRect, lastColor);
if (currentDecorations & QQuickTextNode::Underline)
pendingUnderlines.append(textDecoration);
if (currentDecorations & QQuickTextNode::Overline)
pendingOverlines.append(textDecoration);
if (currentDecorations & QQuickTextNode::StrikeOut)
pendingStrikeOuts.append(textDecoration);
if (currentDecorations & QQuickTextNode::Background)
m_backgrounds.append(qMakePair(decorationRect, lastBackgroundColor));
}
// If we've reached an unselected node from a selected node, we add the
// selection rect to the graph, and we add decoration every time the
// selection state changes, because that means the text color changes
if (node == 0 || node->selectionState != currentSelectionState) {
currentRect.setY(m_position.y() + m_currentLine.y());
currentRect.setHeight(m_currentLine.height());
if (currentSelectionState == Selected)
m_selectionRects.append(currentRect);
if (currentClipNode != 0) {
if (!currentClipNodeUsed) {
delete currentClipNode;
} else {
currentClipNode->setIsRectangular(true);
currentClipNode->setRect(currentRect);
currentClipNode->update();
}
}
if (node != 0 && m_hasSelection)
currentClipNode = new QQuickDefaultClipNode(QRectF());
else
currentClipNode = 0;
currentClipNodeUsed = false;
//.........这里部分代码省略.........