本文整理汇总了C++中QRawFont::pathForGlyph方法的典型用法代码示例。如果您正苦于以下问题:C++ QRawFont::pathForGlyph方法的具体用法?C++ QRawFont::pathForGlyph怎么用?C++ QRawFont::pathForGlyph使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类QRawFont
的用法示例。
在下文中一共展示了QRawFont::pathForGlyph方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: handleGlyphRun_
void BoxBuilder::handleGlyphRun_(const QGlyphRun& glyphRun)
{
QPainter painter_(&pixmap_);
painter_.setPen(glyphPen_);
painter_.drawGlyphRun(glyphPosition_,glyphRun);
QVector<quint32> indices = glyphRun.glyphIndexes();
QVector<QPointF> positions = glyphRun.positions();
if(indices.size() != positions.size())
log_ << "the number of indices and the number of positions are different: "
<< indices.size() << " and " << positions.size() << std::endl;
QVector<QPointF>::Iterator posit = positions.begin();
qreal posx = glyphPosition_.x(),
posy = glyphPosition_.y();
for(QVector<quint32>::iterator ixIt = indices.begin();ixIt != indices.end();++ixIt)
{
QRawFont rawFont = glyphRun.rawFont();
QPainterPath painterPath = rawFont.pathForGlyph(*ixIt);
QRectF glyphBoundingRect = painterPath.boundingRect();
QVector<uint> blockTextIndices(blockText_.length());
int blockTextIndicesSize = blockTextIndices.size();
rawFont.glyphIndexesForChars(blockText_.begin(),blockText_.length(),blockTextIndices.begin(),&blockTextIndicesSize);
std::map<uint,QChar> glyphIndicesToChars;
std::wstring blockTextStdw = blockText_.toStdWString();
// build index for acessing chars in text, since glyphs order may not correspond chars order in text
for(int i = 0; i < blockTextIndices.size(); ++i)
glyphIndicesToChars[blockTextIndices[i] ] = blockText_.at(i);
QChar currentChar = glyphIndicesToChars[*ixIt];
unsigned histValue = 0;
if(histogram.find(currentChar) == histogram.end())
histogram[currentChar] = 0;
else histValue = ++histogram[currentChar];
maxHistogramValue = std::max(maxHistogramValue,histValue);
//std::wcout << "processing \" "<< QString(currentChar).toStdWString() << " \"... " << std::endl;
//
//
//log_ << "glyphBoundingRect = (" << glyphBoundingRect.x() << "," << glyphBoundingRect.y() <<
// "," << glyphBoundingRect.width() << "," << glyphBoundingRect.height() << ")" << std::endl;
QRect screenBoundingRect(
posx + posit->x() + glyphBoundingRect.x(),
posy + posit->y() + glyphBoundingRect.y(),
glyphBoundingRect.width()+1,
glyphBoundingRect.height()+1);
/* log_ << "screen layout position = (" << posx << "," << posy << ")" << std::endl;
log_ << "screen glyph position = (" << posit->x() << "," << posit->y() << ")" << std::endl;
log_ << "screenBoundingRect = (" << screenBoundingRect.x() << "," << screenBoundingRect.y() <<
"," << screenBoundingRect.width() << "," << screenBoundingRect.height() << ")" << std::end*/;
QRect imageBoundingRect(QPoint( screenBoundingRect.x(),
pixmap_.height()-1 - screenBoundingRect.y() - screenBoundingRect.height()+1),
QPoint( screenBoundingRect.x() + screenBoundingRect.width()-1,
pixmap_.height() - screenBoundingRect.y()-1)
);
//log_ << "imageBoundingRect = (" << imageBoundingRect.x() << "," << imageBoundingRect.y() <<
// "," << imageBoundingRect.width() << "," << imageBoundingRect.height() << ")" << std::endl;
if(glyphBoundingRect.width()&&glyphBoundingRect.height())
boxes_.push_back(box(glyphIndicesToChars[*ixIt],imageBoundingRect));
//painter_.setPen(boxPen_);
painter_.setPen(Qt::green);
//painter_.drawRect(screenBoundingRect);
++posit;
}
}