Logo Search packages:      
Sourcecode: qt4-x11 version File versions

QRect QFontMetrics::boundingRect ( QChar  ch  )  const

Returns the rectangle that is covered by ink if character ch were to be drawn at the origin of the coordinate system.

Note that the bounding rectangle may extend to the left of (0, 0), e.g. for italicized fonts, and that the text output may cover all pixels in the bounding rectangle. For a space character the rectangle will usually be empty.

Note that the rectangle usually extends both above and below the base line.

The width of the returned rectangle is not the advance width of the character. Use boundingRect(const QString &) or width() instead.
See also:

Definition at line 689 of file qfontmetrics.cpp.

References QChar::isLower().

Referenced by Q3CanvasText::draw(), QCommonStyle::drawControl(), GLWidget::drawInstructions(), QStyle::itemTextRect(), QCalendarWidget::minimumSizeHint(), size(), Q3TableItem::sizeHint(), and QCleanlooksStyle::subControlRect().

    const int script = QUnicodeTables::script(ch);
    QFontEngine *engine;
    if (d->capital == QFont::SmallCaps && ch.isLower())
        engine = d->smallCapsFontPrivate()->engineForScript(script);
        engine = d->engineForScript(script);
    Q_ASSERT(engine != 0);


    QGlyphLayout glyphs[10];
    int nglyphs = 9;
    engine->stringToCMap(&ch, 1, glyphs, &nglyphs, 0);
    glyph_metrics_t gm = engine->boundingBox(glyphs[0].glyph);
    return QRect(qRound(gm.x), qRound(gm.y), qRound(gm.width), qRound(gm.height));

Generated by  Doxygen 1.6.0   Back to index