本文整理汇总了C++中QRawFont::glyphIndexesForString方法的典型用法代码示例。如果您正苦于以下问题:C++ QRawFont::glyphIndexesForString方法的具体用法?C++ QRawFont::glyphIndexesForString怎么用?C++ QRawFont::glyphIndexesForString使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类QRawFont
的用法示例。
在下文中一共展示了QRawFont::glyphIndexesForString方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: genGlyphs
void Sym::genGlyphs(const QRawFont& rfont)
{
QVector<quint32> idx = rfont.glyphIndexesForString(toString());
QVector<QPointF> adv;
adv << QPointF();
glyphs.setGlyphIndexes(idx);
glyphs.setPositions(adv);
glyphs.setRawFont(rfont);
}
示例2: invalidRawFont
void tst_QRawFont::invalidRawFont()
{
QRawFont font;
QVERIFY(!font.isValid());
QCOMPARE(font.pixelSize(), 0.0);
QVERIFY(font.familyName().isEmpty());
QCOMPARE(font.style(), QFont::StyleNormal);
QCOMPARE(font.weight(), -1);
QCOMPARE(font.ascent(), 0.0);
QCOMPARE(font.descent(), 0.0);
QVERIFY(font.glyphIndexesForString(QLatin1String("Test")).isEmpty());
}
示例3: fill
bool GlyphPage::fill(unsigned offset, unsigned length, UChar* buffer, unsigned bufferLength, const SimpleFontData* fontData)
{
QRawFont rawFont = fontData->platformData().rawFont();
QString qstring = QString::fromRawData(reinterpret_cast<const QChar*>(buffer), static_cast<int>(bufferLength));
QVector<quint32> indexes = rawFont.glyphIndexesForString(qstring);
bool haveGlyphs = false;
for (unsigned i = 0; i < length; ++i) {
Glyph glyph = (i < indexes.size()) ? indexes.at(i) : 0;
if (!glyph)
setGlyphDataForIndex(offset + i, 0, 0);
else {
haveGlyphs = true;
setGlyphDataForIndex(offset + i, glyph, fontData);
}
}
return haveGlyphs;
}
示例4: draw
void Rest::draw(QPainter* painter) const
{
if ( (staff() && staff()->isTabStaff()
// in tab staff, do not draw rests is rests are off OR if dur. symbols are on
&& ( !((StaffTypeTablature*)staff()->staffType())->showRests()
|| ((StaffTypeTablature*)staff()->staffType())->genDurations()) )
|| generated())
return;
qreal _spatium = spatium();
painter->setPen(curColor());
if (parent() && measure() && measure()->multiMeasure()) {
Measure* m = measure();
int n = m->multiMeasure();
qreal pw = _spatium * .7;
QPen pen(painter->pen());
pen.setWidthF(pw);
painter->setPen(pen);
qreal w = _mmWidth;
qreal y = 0.0;
qreal x1 = 0.0;
qreal x2 = w;
pw *= .5;
painter->drawLine(QLineF(x1 + pw, y, x2 - pw, y));
// draw vertical lines:
pen.setWidthF(_spatium * .2);
painter->setPen(pen);
painter->drawLine(QLineF(x1, y-_spatium, x1, y+_spatium));
painter->drawLine(QLineF(x2, y-_spatium, x2, y+_spatium));
#ifdef USE_GLYPHS
QRawFont rfont = fontId2RawFont(0);
rfont.setPixelSize(20.0 * spatium()/(PPI * SPATIUM20));
QGlyphRun glyphs;
QVector<quint32> idx = rfont.glyphIndexesForString(QString("%1").arg(n));
glyphs.setGlyphIndexes(idx);
QVector<QPointF> adv = rfont.advancesForGlyphIndexes(idx);
adv.insert(0, QPointF());
glyphs.setPositions(adv);
glyphs.setRawFont(rfont);
QRectF r = glyphs.boundingRect();
y = -_spatium * .5;
painter->drawGlyphRun(QPointF((x2 - x1) * .5 + x1 - r.width() * .5, y), glyphs);
#else
QFont font = fontId2font(0);
font.setPixelSize(lrint(20.0 * spatium()/(PPI * SPATIUM20)));
painter->setFont(font);
QFontMetricsF fm(font);
// y = -_spatium * .5 - (staff()->height()*.5) - fm.ascent();
y = -_spatium * .5 - fm.ascent();
painter->drawText(QRectF(center(x1, x2), y, .0, .0),
Qt::AlignHCenter|Qt::TextDontClip,
QString("%1").arg(n));
#endif
}
else {
qreal mag = magS();
symbols[score()->symIdx()][_sym].draw(painter, mag);
int dots = durationType().dots();
if (dots) {
qreal y = dotline * _spatium * .5;
for (int i = 1; i <= dots; ++i) {
qreal x = symbols[score()->symIdx()][_sym].width(mag)
+ point(score()->styleS(ST_dotNoteDistance)) * i;
symbols[score()->symIdx()][dotSym].draw(painter, mag, QPointF(x, y));
}
}
}
}