66 #if !defined(QT_NO_FREETYPE) 72 #define ObjectSelectionBrush (QTextFormat::ForegroundBrush + 1) 73 #define SuppressText 0x5012 74 #define SuppressBackground 0x513 368 f =
QFont(font, paintdevice);
403 d->resetFontEngineCache();
475 if (
d->specialData->addFormats.isEmpty()) {
476 delete d->specialData;
479 d->specialData->preeditText =
QString();
480 d->specialData->preeditPosition = -1;
485 d->specialData->preeditPosition =
position;
486 d->specialData->preeditText =
text;
490 if (
d->block.docHandle())
491 d->block.docHandle()->documentChange(
d->block.position(),
d->block.length());
502 return d->specialData ?
d->specialData->preeditPosition : -1;
512 return d->specialData ?
d->specialData->preeditText :
QString();
526 if (
d->specialData->preeditText.isEmpty()) {
527 delete d->specialData;
530 d->specialData->addFormats = formatList;
531 d->specialData->addFormatIndices.clear();
534 if (!
d->specialData) {
536 d->specialData->preeditPosition = -1;
538 d->specialData->addFormats = formatList;
539 d->indexAdditionalFormats();
541 if (
d->block.docHandle())
542 d->block.docHandle()->documentChange(
d->block.position(),
d->block.length());
543 d->resetFontEngineCache();
557 formats =
d->specialData->addFormats;
559 if (
d->specialData->addFormatIndices.isEmpty())
564 for (
int i = 0; i <
d->specialData->addFormatIndices.count(); ++i)
565 formats[i].
format = collection->
charFormat(
d->specialData->addFormatIndices.at(i));
592 d->cacheGlyphs = enable;
603 return d->cacheGlyphs;
649 qWarning(
"QTextLayout::beginLayout: Called while already doing layout");
668 qWarning(
"QTextLayout::endLayout: Called without beginLayout()");
672 int l =
d->lines.size();
673 if (l &&
d->lines.at(l-1).length < 0) {
704 const HB_CharAttributes *attributes =
d->attributes();
705 int len =
d->block.isValid() ?
d->block.length() - 1
706 :
d->layoutData->string.length();
707 Q_ASSERT(len <= d->layoutData->string.length());
708 if (!attributes || oldPos < 0 || oldPos >= len)
711 if (mode == SkipCharacters) {
713 while (oldPos < len && !attributes[oldPos].charStop)
716 if (oldPos < len && d->atWordSeparator(oldPos)) {
718 while (oldPos < len && d->atWordSeparator(oldPos))
721 while (oldPos < len && !d->atSpace(oldPos) && !
d->atWordSeparator(oldPos))
724 while (oldPos < len && d->atSpace(oldPos))
740 const HB_CharAttributes *attributes =
d->attributes();
741 if (!attributes || oldPos <= 0 || oldPos >
d->layoutData->string.length())
744 if (mode == SkipCharacters) {
746 while (oldPos && !attributes[oldPos].charStop)
749 while (oldPos &&
d->atSpace(oldPos-1))
752 if (oldPos &&
d->atWordSeparator(oldPos-1)) {
754 while (oldPos &&
d->atWordSeparator(oldPos-1))
757 while (oldPos && !
d->atSpace(oldPos-1) && !
d->atWordSeparator(oldPos-1))
820 const HB_CharAttributes *attributes =
d->attributes();
821 if (!attributes || pos < 0 || pos > (
int)
d->layoutData->string.length())
823 return attributes[pos].charStop;
846 qWarning(
"QTextLayout::createLine: Called without layouting");
853 int l =
d->lines.size();
854 if (l &&
d->lines.at(l-1).length < 0) {
857 int from = l > 0 ?
d->lines.at(l-1).from +
d->lines.at(l-1).length +
d->lines.at(l-1).trailingSpaces : 0;
858 int strlen =
d->layoutData->string.length();
859 if (l && from >= strlen) {
870 d->lines.append(line);
881 return d->lines.size();
901 int lineNum =
d->lineNumberForTextPosition(pos);
902 return lineNum >= 0 ? lineAt(lineNum) :
QTextLine();
936 if (
d->lines.isEmpty())
940 QFixed xmin =
d->lines.at(0).x;
941 QFixed ymin =
d->lines.at(0).y;
943 for (
int i = 0; i <
d->lines.size(); ++i) {
945 xmin =
qMin(xmin, si.
x);
946 ymin =
qMin(ymin, si.
y);
948 xmax =
qMax(xmax, si.
x+lineWidth);
966 return d->minWidth.toReal();
980 return d->maxWidth.toReal();
991 d->forceJustification =
true;
995 d->ignoreBidi =
true;
1012 QFixed lastSelectionX = iterator.
x;
1013 QFixed lastSelectionWidth;
1015 while (!iterator.
atEnd()) {
1018 QFixed selectionX, selectionWidth;
1020 if (selectionX == lastSelectionX + lastSelectionWidth) {
1021 lastSelectionWidth += selectionWidth;
1025 if (lastSelectionWidth > 0) {
1032 lastSelectionX = selectionX;
1033 lastSelectionWidth = selectionWidth;
1036 if (lastSelectionWidth > 0) {
1046 return clip.
isValid() ? (rect & clip) : rect;
1058 #if !defined(QT_NO_RAWFONT) 1062 for (
int i=0; i<
d->lines.size(); ++i)
1067 #endif // QT_NO_RAWFONT 1076 if (
d->lines.isEmpty())
1084 QFixed clipy = (INT_MIN/256);
1092 int lastLine =
d->lines.size();
1093 for (
int i = 0; i <
d->lines.size(); ++i) {
1101 if ((sl.
y + sl.
height()) < clipy) {
1109 for (
int i = 0; i < selections.
size(); ++i) {
1116 for (
int line = firstLine; line < lastLine; ++line) {
1122 lineRect.adjust(0, 0,
d->leadingSpaceWidth(sl).toReal(), 0);
1124 bool isLastLineInBlock = (line ==
d->lines.size()-1);
1125 int sl_length = sl.
length + (isLastLineInBlock? 1 : 0);
1131 const bool selectionStartInLine = sl.
from <= selection.
start;
1132 const bool selectionEndInLine = selection.
start + selection.
length < sl.
from + sl_length;
1134 if (sl.
length && (selectionStartInLine || selectionEndInLine)) {
1144 if (!selectionEndInLine)
1146 if (!selectionStartInLine)
1148 }
else if (!selectionEndInLine
1149 && isLastLineInBlock
1152 lineRect.height()/4, lineRect.height()), clip));
1173 if (hasBackground) {
1183 if (hasText && !hasBackground && !(textDoneRegion & region).
isEmpty())
1189 for (
int line = firstLine; line < lastLine; ++line) {
1191 l.
draw(p, position, &selection);
1196 textDoneRegion += region;
1199 textDoneRegion -= region;
1202 excludedRegion += region;
1205 QPainterPath needsTextButNoBackground = excludedRegion - textDoneRegion;
1206 if (!needsTextButNoBackground.
isEmpty()){
1210 selection.
start = 0;
1213 for (
int line = firstLine; line < lastLine; ++line) {
1215 l.
draw(p, position, &selection);
1220 if (!excludedRegion.
isEmpty()) {
1228 path -= excludedRegion;
1232 for (
int i = firstLine; i < lastLine; ++i) {
1234 l.
draw(p, position);
1236 if (!excludedRegion.
isEmpty())
1240 if (!
d->cacheGlyphs)
1254 drawCursor(p, pos, cursorPosition, 1);
1266 if (
d->lines.isEmpty())
1274 cursorPosition =
qBound(0, cursorPosition,
d->layoutData->string.length());
1275 int line =
d->lineNumberForTextPosition(cursorPosition);
1278 if (line >=
d->lines.size())
1288 if (
d->visualCursorMovement()) {
1291 itm =
d->findItem(cursorPosition);
1293 itm =
d->findItem(cursorPosition - 1);
1297 bool rightToLeft =
d->isRightToLeft();
1309 if (toggleAntialiasing)
1311 #if defined(QT_MAC_USE_COCOA) 1316 if (toggleAntialiasing)
1318 if (
d->layoutData->hasBidi) {
1319 const int arrow_extent = 4;
1320 int sign = rightToLeft ? -1 : 1;
1321 p->
drawLine(
QLineF(x, y, x + (sign * arrow_extent/2), y + arrow_extent/2));
1322 p->
drawLine(
QLineF(x, y+arrow_extent, x + (sign * arrow_extent/2), y + arrow_extent/2));
1452 return eng->
lines[i].width.toReal();
1463 return eng->
lines[i].ascent.toReal();
1473 return eng->
lines[i].descent.toReal();
1485 return eng->
lines[i].height().toReal();
1500 return eng->
lines[i].leading.toReal();
1522 eng->
lines[i].leadingIncluded= included;
1541 return eng->
lines[i].leadingIncluded;
1551 return eng->
lines[i].textWidth.toReal();
1569 return eng->
lines[i].textAdvance.toReal();
1583 qWarning(
"QTextLine: Can't set a line width while not layouting.");
1616 layout_helper(numColumns);
1633 layout_helper(numColumns);
1637 #define LB_DEBUG qDebug 1639 #define LB_DEBUG if (0) qDebug 1644 struct LineBreakHelper
1647 : glyphCount(0), maxGlyphs(0), currentPosition(0), fontEngine(0), logClusters(0),
1648 manualWrap(
false), whiteSpaceOrObject(
true)
1660 int currentPosition;
1666 QFixed minimumRightBearing;
1670 const unsigned short *logClusters;
1673 bool whiteSpaceOrObject;
1682 inline glyph_t currentGlyph()
const 1687 return glyphs.
glyphs[logClusters[currentPosition - 1]];
1690 inline void resetPreviousGlyph()
1693 previousFontEngine = 0;
1696 inline void saveCurrentGlyph()
1698 resetPreviousGlyph();
1699 if (currentPosition > 0 &&
1700 logClusters[currentPosition - 1] < glyphs.
numGlyphs) {
1701 previousGlyph = currentGlyph();
1702 previousFontEngine = fontEngine;
1706 inline void adjustRightBearing(
glyph_t glyph)
1713 inline void adjustRightBearing()
1715 if (currentPosition <= 0)
1717 adjustRightBearing(currentGlyph());
1720 inline void adjustPreviousRightBearing()
1722 if (previousGlyph > 0 && previousFontEngine) {
1729 inline void resetRightBearing()
1731 rightBearing =
QFixed(1);
1736 inline bool LineBreakHelper::checkFullOtherwiseExtend(
QScriptLine &line)
1738 LB_DEBUG(
"possible break width %f, spacew=%f", tmpData.textWidth.toReal(), spaceData.textWidth.toReal());
1740 QFixed newWidth = calculateNewWidth(line);
1741 if (line.
length && !manualWrap && (newWidth > line.
width || glyphCount > maxGlyphs))
1744 minw =
qMax(minw, tmpData.textWidth);
1748 line.
length += spaceData.length;
1749 tmpData.textWidth = 0;
1751 spaceData.textWidth = 0;
1752 spaceData.length = 0;
1761 const QScriptItem ¤t,
const unsigned short *logClusters,
1764 int glyphPosition = logClusters[pos];
1768 }
while (pos < end && logClusters[pos] == glyphPosition);
1770 if (!glyphs.
attributes[glyphPosition].dontPrint)
1773 }
while (glyphPosition < current.
num_glyphs && !glyphs.
attributes[glyphPosition].clusterStart);
1775 Q_ASSERT((pos == end && glyphPosition == current.
num_glyphs) || logClusters[pos] == glyphPosition);
1797 LineBreakHelper lbh;
1799 lbh.maxGlyphs = maxGlyphs;
1815 lbh.currentPosition = line.
from;
1818 lbh.resetPreviousGlyph();
1820 while (newItem < eng->layoutData->items.size()) {
1821 lbh.resetRightBearing();
1822 lbh.softHyphenWidth = 0;
1823 if (newItem != item) {
1837 if (lbh.fontEngine != fontEngine) {
1838 lbh.fontEngine = fontEngine;
1845 lbh.tmpData.leading =
qMax(lbh.tmpData.leading + lbh.tmpData.ascent,
1848 lbh.tmpData.ascent =
qMax(lbh.tmpData.ascent, current.
ascent);
1849 lbh.tmpData.descent =
qMax(lbh.tmpData.descent, current.
descent);
1852 lbh.whiteSpaceOrObject =
true;
1853 if (lbh.checkFullOtherwiseExtend(line))
1856 QFixed x = line.
x + line.
textWidth + lbh.tmpData.textWidth + lbh.spaceData.textWidth;
1859 lbh.spaceData.textWidth += tabWidth;
1860 lbh.spaceData.length++;
1864 lbh.glyphCount +=
qRound(tabWidth / averageCharWidth);
1866 if (lbh.checkFullOtherwiseExtend(line))
1869 lbh.whiteSpaceOrObject =
true;
1872 if (!line.
length && !lbh.tmpData.length)
1875 addNextCluster(lbh.currentPosition, end, lbh.tmpData, lbh.glyphCount,
1876 current, lbh.logClusters, lbh.glyphs);
1878 lbh.tmpData.length++;
1879 lbh.adjustPreviousRightBearing();
1881 line += lbh.tmpData;
1884 lbh.whiteSpaceOrObject =
true;
1891 lbh.tmpData.textWidth += current.
width;
1895 if (lbh.checkFullOtherwiseExtend(line))
1897 }
else if (attributes[lbh.currentPosition].whiteSpace) {
1898 lbh.whiteSpaceOrObject =
true;
1899 while (lbh.currentPosition < end && attributes[lbh.currentPosition].whiteSpace)
1900 addNextCluster(lbh.currentPosition, end, lbh.spaceData, lbh.glyphCount,
1901 current, lbh.logClusters, lbh.glyphs);
1903 if (!lbh.manualWrap && lbh.spaceData.textWidth > line.
width) {
1904 lbh.spaceData.textWidth = line.
width;
1908 lbh.whiteSpaceOrObject =
false;
1909 bool sb_or_ws =
false;
1910 lbh.saveCurrentGlyph();
1912 addNextCluster(lbh.currentPosition, end, lbh.tmpData, lbh.glyphCount,
1913 current, lbh.logClusters, lbh.glyphs);
1915 if (attributes[lbh.currentPosition].whiteSpace || attributes[lbh.currentPosition-1].lineBreakType != HB_NoBreak) {
1918 }
else if (breakany && attributes[lbh.currentPosition].charStop) {
1921 }
while (lbh.currentPosition < end);
1922 lbh.minw =
qMax(lbh.tmpData.textWidth, lbh.minw);
1924 if (lbh.currentPosition && attributes[lbh.currentPosition - 1].lineBreakType == HB_SoftHyphen) {
1942 lbh.softHyphenWidth = lbh.glyphs.advances_x[lbh.logClusters[lbh.currentPosition - 1]];
1944 lbh.tmpData.textWidth += lbh.glyphs.advances_x[lbh.logClusters[lbh.currentPosition - 1]];
1953 if (sb_or_ws|breakany) {
1954 QFixed rightBearing = lbh.rightBearing;
1955 #if !defined(Q_WS_MAC) 1956 if (lbh.calculateNewWidth(line) - lbh.minimumRightBearing > line.
width)
1958 lbh.adjustRightBearing();
1959 if (lbh.checkFullOtherwiseExtend(line)) {
1961 if (rightBearing <= 0)
1962 lbh.rightBearing = rightBearing;
1964 lbh.adjustPreviousRightBearing();
1973 lbh.saveCurrentGlyph();
1975 if (lbh.currentPosition == end)
1979 lbh.checkFullOtherwiseExtend(line);
1981 if (lbh.rightBearing > 0 && !lbh.whiteSpaceOrObject)
1982 lbh.adjustRightBearing();
1987 LB_DEBUG(
"no break available in line, adding temp: length %d, width %f, space: length %d, width %f",
1988 lbh.tmpData.length, lbh.tmpData.textWidth.toReal(),
1989 lbh.spaceData.length, lbh.spaceData.textWidth.toReal());
1990 line += lbh.tmpData;
1997 if (lbh.manualWrap) {
2005 if (line.
textWidth > 0 && item < eng->layoutData->items.size())
2008 line.
textWidth += lbh.spaceData.textWidth;
2009 if (lbh.spaceData.length) {
2018 if ((lbh.maxGlyphs !=
INT_MAX && lbh.glyphCount > lbh.maxGlyphs)
2024 layout_helper(lbh.maxGlyphs);
2078 int start,
int glyph_start)
2081 int gs = glyph_start;
2083 unsigned short *logClusters = eng->
logClusters(&si);
2089 while (*ul != -1 && *ul < start)
2098 if (ul && *ul != -1 && *ul < end) {
2100 gtmp = logClusters[*ul-si.
position];
2119 if (ul && *ul != -1 && *ul < end) {
2121 gtmp = (*ul == end-1) ? ge : logClusters[*ul+1-si.
position];
2146 gf.
width = orig_width;
2170 const QTextItemInt::RenderFlags &renderFlags)
2171 : glyphLayout(layout), itemPosition(position), flags(renderFlags)
2177 QTextItem::RenderFlags flags;
2196 #if !defined(QT_NO_RAWFONT) 2208 while (!iterator.
atEnd()) {
2214 if (from >= 0 && length >= 0 &&
2220 QTextItem::RenderFlags flags;
2239 int which = glyphLayout.
glyphs[0] >> 24;
2241 const int e = glyphLayout.
glyphs[
end] >> 24;
2246 glyphLayoutHash.insertMulti(multiFontEngine->
engine(which),
2247 GlyphInfo(subLayout, pos, flags));
2248 for (
int i = 0; i < subLayout.
numGlyphs; i++)
2257 glyphLayoutHash.insertMulti(multiFontEngine->
engine(which),
2258 GlyphInfo(subLayout, pos, flags));
2261 glyphLayoutHash.insertMulti(mainFontEngine,
2262 GlyphInfo(glyphLayout, pos, flags));
2270 for (
int i=0; i<keys.
size(); ++i) {
2279 #if defined(Q_WS_WIN) 2284 #elif defined(Q_WS_MAC)
2286 #elif !defined(QT_NO_FREETYPE) 2305 for (
int j=0; j<glyphLayouts.
size(); ++j) {
2306 const QPointF &pos = glyphLayouts.
at(j).itemPosition;
2307 const QGlyphLayout &glyphLayout = glyphLayouts.
at(j).glyphLayout;
2308 const QTextItem::RenderFlags &flags = glyphLayouts.
at(j).flags;
2319 for (
int i=0; i<glyphsArray.
size(); ++i) {
2320 glyphs.append(glyphsArray.
at(i) & 0xffffff);
2335 glyphsHash.
insert(key, glyphIndexes);
2351 return glyphsHash.
values();
2353 #endif // QT_NO_RAWFONT 2389 while (!iterator.
atEnd()) {
2405 if (suppressColors) {
2421 itemBaseLine += height / 6;
2423 itemBaseLine -= height / 2;
2434 itemY = y - lineBase;
2459 QChar visualTab(0x2192);
2488 gf.initWithScriptItem(si);
2501 if (gf.glyphs.numGlyphs)
2502 gf.fontEngine->addOutlineToPath(pos.
x(), pos.
y(), gf.glyphs, &path, gf.flags);
2508 path.
addRect(pos.
x(), pos.
y() + offs, gf.width.toReal(), lw);
2512 path.
addRect(pos.
x(), pos.
y() - offs, gf.width.toReal(), lw);
2516 path.
addRect(pos.
x(), pos.
y() - offs, gf.width.toReal(), lw);
2534 gf.glyphs.numGlyphs = 0;
2587 int pos = *cursorPos;
2594 while (pos < lineEnd && !attributes[pos].charStop)
2596 if (pos == lineEnd) {
2619 int glyph_pos = pos == l ? si->
num_glyphs : logClusters[pos];
2620 if (edge == Trailing) {
2622 while (glyph_pos < si->num_glyphs && !glyphs.
attributes[glyph_pos].clusterStart)
2633 int nItems = (firstItem >= 0 && lastItem >= firstItem)? (lastItem-firstItem+1) : 0;
2637 for (
int i = 0; i < nItems; ++i)
2641 for (
int i = 0; i < nItems; ++i) {
2642 int item = visualOrder[i]+firstItem;
2658 int gs = logClusters[start-si.
position];
2672 if (pos == (reverse ? 0 : l))
2679 int glyph_end = end == l ? si->
num_glyphs : logClusters[
end];
2680 int glyph_start = glyph_pos;
2681 if (visual && !rtl && !(lastLine && itm == (visualOrder[nItems - 1] + firstItem)))
2683 for (
int i = glyph_end - 1; i >= glyph_start; i--)
2687 int glyph_start = logClusters[start];
2688 int glyph_end = glyph_pos;
2689 if (!visual || !rtl || (lastLine && itm == visualOrder[0] + firstItem))
2691 for (
int i = glyph_start; i <= glyph_end; i++)
2728 int line_length = textLength();
2735 int nItems = (firstItem >= 0 && lastItem >= firstItem)? (lastItem-firstItem+1) : 0;
2746 for (
int i = 0; i < nItems; ++i)
2753 int item = visualOrder[0]+firstItem;
2761 pos =
qMin(line.
from + line_length, pos);
2774 for (
int i = 0; i < nItems; ++i) {
2775 int item = visualOrder[i]+firstItem;
2785 int gs = logClusters[start];
2786 int ge = (end == item_length ? si.
num_glyphs : logClusters[
end]) - 1;
2791 item_width = si.
width;
2801 if (pos + item_width < x) {
2810 bool left_half = (x - pos) < item_width/2;
2851 if (!visual || rtl || (lastLine && i == nItems - 1)) {
2874 if (!visual || !rtl || (lastLine && i == 0)) {
2898 if (
qAbs(x-pos) < dist) {
2900 if (!rtl && i < nItems - 1) {
2904 if (rtl && nchars > 0)
2905 return insertionPoints[lastLine ? nchars : nchars - 1];
2918 int item = visualOrder[nItems-1]+firstItem;
2927 int maxPos = line.
from + line_length;
2934 if (this->i < eng->lines.count() - 1)
2937 pos =
qMin(pos, maxPos);
The QPainter class performs low-level painting on widgets and other paint devices.
virtual QFixed lineThickness() const
The QColor class provides colors based on RGB, HSV or CMYK values.
QTextCharFormat format(const QScriptItem *si) const
void setAdditionalFormats(const QList< FormatRange > &overrides)
Sets the additional formats supported by the text layout to formatList.
static void addSelectedRegionsToPath(QTextEngine *eng, int lineNumber, const QPointF &pos, QTextLayout::FormatRange *selection, QPainterPath *region, QRectF boundingRect)
QTextCharFormat charFormat(int index) const
void moveTop(qreal pos)
Moves the rectangle vertically, leaving the rectangle's top line at the given y coordinate.
QTextOption textOption() const
Returns the current text option used to control the layout process.
virtual qreal minRightBearing() const
bool isEmpty() const
Returns true if either there are no elements in this path, or if the only element is a MoveToElement;...
qreal descent() const
Returns the line's descent.
void setText(const QString &string)
Sets the layout's text to the given string.
The QTextLayout::FormatRange structure is used to apply extra formatting information for a specified ...
virtual QFixed averageCharWidth() const
qreal y() const
Returns the y-coordinate of the rectangle's top edge.
bool isRightToLeft() const
int width(const QString &, int len=-1) const
Returns the width in pixels of the first len characters of text.
unsigned short trailingSpaces
bool isValidCursorPosition(int pos) const
/ Returns true if position pos is a valid cursor position.
void drawPath(const QPainterPath &path)
Draws the given painter path using the current pen for outline and the current brush for filling...
QFont font(const QScriptItem &si) const
QPointF position() const
The global position of the layout.
The QTextCharFormat class provides formatting information for characters in a QTextDocument.
Q_DECL_CONSTEXPR const T & qMin(const T &a, const T &b)
The QFontMetrics class provides font metrics information.
void setStrikeOut(bool strikeOut)
Indicates that this QGlyphRun should be painted with an strike out decoration if strikeOut is true...
const QTransform & transform() const
Returns the world transformation matrix.
#define QT_END_NAMESPACE
This macro expands to.
qreal y() const
Returns the line's y position.
void clearAdditionalFormats()
Clears the list of additional formats supported by the text layout.
const QColor & color() const
Returns the brush color.
QRectF rect() const
Returns the line's bounding rectangle.
qreal horizontalAdvance() const
Returns the horizontal advance of the text.
void setPosition(const QPointF &pos)
Moves the line to position pos.
static void addNextCluster(int &pos, int end, QScriptLine &line, int &glyphCount, const QScriptItem ¤t, const unsigned short *logClusters, const QGlyphLayout &glyphs)
char * data()
Returns a pointer to the data stored in the byte array.
bool isValid() const
Returns true if the rectangle is valid, otherwise returns false.
qreal maximumWidth() const
The maximum width the layout could expand to; this is essentially the width of the entire text...
void moveLeft(qreal pos)
Moves the rectangle horizontally, leaving the rectangle's left edge at the given x coordinate...
static void drawMenuText(QPainter *p, QFixed x, QFixed y, const QScriptItem &si, QTextItemInt &gf, QTextEngine *eng, int start, int glyph_start)
void setUnderline(bool underline)
Indicates that this QGlyphRun should be painted with an underline decoration if underline is true...
The QPainterPath class provides a container for painting operations, enabling graphical shapes to be ...
int count(const T &t) const
Returns the number of occurrences of value in the vector.
bool underline() const
Returns true if underline has been set; otherwise returns false.
QList< QGlyphRun > glyphs(int from, int length) const
Returns the glyph indexes and positions for all glyphs in this QTextLine which reside in QScriptItems...
void setProperty(int propertyId, const QVariant &value)
Sets the property specified by the propertyId to the given value.
QFixed calculateTabWidth(int index, QFixed x) const
returns the width of tab at index (in the tabs array) with the tab-start at position x ...
Qt::PenStyle style() const
Returns the pen style.
static QRectF clipIfValid(const QRectF &rect, const QRectF &clip)
QByteArray toUtf8() const Q_REQUIRED_RESULT
Returns a UTF-8 representation of the string as a QByteArray.
virtual void drawInlineObject(QPainter *painter, const QRectF &rect, QTextInlineObject object, int posInDocument, const QTextFormat &format)
This function is called to draw the inline object, object, with the given painter within the rectangl...
void setPositions(const QVector< QPointF > &positions)
Sets the positions of the edge of the baseline for each glyph in this set of glyph indexes to positio...
QBrush brushProperty(int propertyId) const
Returns the value of the property given by propertyId; if the property isn't of QVariant::Brush type...
static C reverse(const C &l)
void setClipRect(const QRectF &, Qt::ClipOperation op=Qt::ReplaceClip)
Enables clipping, and sets the clip region to the given rectangle using the given clip operation...
int length() const
Returns the number of characters in this string.
void clearBackground()
Clears the brush used to paint the document's background.
The QPointF class defines a point in the plane using floating point precision.
void setFont(const QFont &f)
Sets the layout's font to the given font.
int findItem(int strPos) const
qreal left() const
Returns the x-coordinate of the rectangle's left edge.
The QTextLine class represents a line of text inside a QTextLayout.
static qreal position(QGraphicsObject *item, QDeclarativeAnchorLine::AnchorLine anchorLine)
static QRawFontPrivate * get(const QRawFont &font)
void restore()
Restores the current painter state (pops a saved state off the stack).
WrapMode
This enum describes how text is wrapped in a document.
int textLength() const
Returns the length of the text in the line.
void drawCursor(QPainter *p, const QPointF &pos, int cursorPosition) const
This is an overloaded member function, provided for convenience. It differs from the above function o...
qreal height() const
Returns the inline object's total height.
void insertionPointsForLine(int lineNum, QVector< int > &insertionPoints)
Flags flags() const
Returns the flags associated with the option.
qreal leading() const
Returns the line's leading.
QFontEngine * fontEngine(const QScriptItem &si, QFixed *ascent=0, QFixed *descent=0, QFixed *leading=0) const
QRectF boundingRect() const
The smallest rectangle that contains all the lines in the layout.
int nextCursorPosition(int oldPos, CursorMode mode=SkipCharacters) const
Returns the next valid cursor position after oldPos that respects the given cursor mode...
bool toBool() const
Returns the variant as a bool if the variant has type() Bool.
const unsigned short * logClusters
long ASN1_INTEGER_get ASN1_INTEGER * a
void setLineWidth(qreal width)
Lays out the line with the given width.
bool ref()
Atomically increments the value of this QAtomicInt.
QFixed offsetInLigature(const QScriptItem *si, int pos, int max, int glyph_pos)
void drawLine(const QLineF &line)
Draws a line defined by line.
int start
Specifies the beginning of the format range within the text layout's text.
QRectF intersected(const QRectF &other) const
Returns the intersection of this rectangle and the given rectangle.
unsigned short * logClusters(const QScriptItem *si) const
The QString class provides a Unicode character string.
qreal ascent() const
Returns the inline object's ascent.
QTextFormat format(int idx) const
The QHash class is a template class that provides a hash-table-based dictionary.
QVector< QPointF > positions() const
Returns the position of the edge of the baseline for each glyph in this set of glyph indexes...
QGlyphLayout mid(int position, int n=-1) const
static QFixed fromReal(qreal r)
Q_DECL_CONSTEXPR T qAbs(const T &t)
The QVector class is a template class that provides a dynamic array.
const HB_CharAttributes * attributes() const
The QPen class defines how a QPainter should draw lines and outlines of shapes.
QFont font() const
Returns the current font that is used for the layout, or a default font if none is set...
virtual Type type() const =0
bool contains(const Key &key) const
Returns true if the hash contains an item with the key; otherwise returns false.
qreal ascent() const
Returns the line's ascent.
The QChar class provides a 16-bit Unicode character.
void clearForeground()
Clears the brush used to paint the document's foreground.
void setRight(qreal pos)
Sets the right edge of the rectangle to the given x coordinate.
void save()
Saves the current painter state (pushes the state onto a stack).
Q_DECL_CONSTEXPR const T & qMax(const T &a, const T &b)
bool isEmpty() const
Returns true if the list contains no items; otherwise returns false.
qreal x() const
Returns the x-coordinate of this point.
iterator insert(const Key &key, const T &value)
Inserts a new item with the key and a value of value.
QTextLine lineForTextPosition(int pos) const
Returns the line that contains the cursor position specified by pos.
void setDescent(qreal d)
Sets the inline object's decent to d.
virtual void getGlyphBearings(glyph_t glyph, qreal *leftBearing=0, qreal *rightBearing=0)
The QLineF class provides a two-dimensional vector using floating point precision.
int position() const
Returns the index of the block's first character within the document.
bool leadingIncluded() const
Returns true if positive leading is included into the line's height; otherwise returns false...
static const QRectF boundingRect(const QPointF *points, int pointCount)
void setFillRule(Qt::FillRule fillRule)
Sets the fill rule of the painter path to the given fillRule.
void setNumColumns(int columns)
Lays out the line.
VerticalAlignment
This enum describes the ways that adjacent characters can be vertically aligned.
QTextLayout()
Constructs an empty text layout.
void shapeLine(const QScriptLine &line)
void drawText(const QPointF &p, const QString &s)
Draws the given text with the currently defined text direction, beginning at the given position...
T * data() const
Returns a pointer to the shared data object.
void setRenderHint(RenderHint hint, bool on=true)
Sets the given render hint on the painter if on is true; otherwise clears the render hint...
qreal cursorToX(int *cursorPos, Edge edge=Leading) const
Converts the cursor position cursorPos to the corresponding x position inside the line...
QString text() const
Returns the layout's text.
const QPen & pen() const
Returns the painter's current pen.
#define QT_BEGIN_NAMESPACE
This macro expands to.
The QRectF class defines a rectangle in the plane using floating point precision. ...
static bool isEmpty(const char *str)
bool overline() const
Returns true if overline has been set; otherwise returns false.
const QChar * unicode() const
Returns a '\0'-terminated Unicode representation of the string.
The QTextFormat class provides formatting information for a QTextDocument.
bool isEmpty() const
Returns true if the string has no characters; otherwise returns false.
void setCursorMoveStyle(Qt::CursorMoveStyle style)
Set the cursor movement style.
QVector< quint32 > glyphIndexes() const
Returns the glyph indexes for this QGlyphRun object.
static const QCssKnownValue positions[NumKnownPositionModes - 1]
qreal height() const
Returns the height of the rectangle.
QGlyphLayout shapedGlyphs(const QScriptItem *si) const
const T & at(int i) const
Returns the item at index position i in the list.
virtual QFixed ascent() const =0
virtual QFixed descent() const =0
static void bidiReorder(int numRuns, const quint8 *levels, int *visualOrder)
void getGlyphPositions(const QGlyphLayout &glyphs, const QTransform &matrix, QTextItem::RenderFlags flags, QVarLengthArray< glyph_t > &glyphs_out, QVarLengthArray< QFixedPoint > &positions)
void append(const T &t)
Inserts value at the end of the vector.
Q_CORE_EXPORT void qWarning(const char *,...)
void layout_helper(int numGlyphs)
The QTextBlock class provides a container for text fragments in a QTextDocument.
qreal x() const
Returns the line's x position.
unsigned short num_glyphs
void addRect(const QRectF &rect)
Adds the given rectangle to this path as a closed subpath.
qreal width() const
Returns the width of the rectangle.
Qt::LayoutDirection textDirection() const
Returns if the object should be laid out right-to-left or left-to-right.
int positionInLigature(const QScriptItem *si, int end, QFixed x, QFixed edge, int glyph_pos, bool cursorOnCharacter)
QBrush brush() const
Returns the brush used to fill strokes generated with this pen.
void draw(QPainter *p, const QPointF &pos, const QVector< FormatRange > &selections=QVector< FormatRange >(), const QRectF &clip=QRectF()) const
Draws the whole layout on the painter p at the position specified by pos.
QBrush background() const
Returns the brush used to paint the document's background.
Qt::BrushStyle style() const
Returns the brush style.
#define SuppressBackground
const T & at(int idx) const
The QGlyphRun class provides direct access to the internal glyphs in a font.
void translate(qreal dx, qreal dy)
Moves the rectangle dx along the x-axis and dy along the y-axis, relative to the current position...
QList< QGlyphRun > glyphRuns() const
Returns the glyph indexes and positions for all glyphs in this QTextLayout.
QTextLine lineAt(int i) const
Returns the {i}-th line of text in this text layout.
int preeditAreaPosition() const
Returns the position of the area in the text layout that will be processed before editing occurs...
const T & at(int i) const
Returns the item at index position i in the vector.
QFontEngine * engineForScript(int script) const
void setLeadingIncluded(bool included)
Includes positive leading into the line's height if included is true; otherwise does not include lead...
const QBrush & brush() const
Returns the painter's current brush.
unsigned short * logClustersPtr
QPointF position() const
Returns the line's position relative to the text layout's position.
The QBrush class defines the fill pattern of shapes drawn by QPainter.
bool isNull() const
Returns true if this string is null; otherwise returns false.
#define ObjectSelectionBrush
QString mid(int position, int n=-1) const Q_REQUIRED_RESULT
Returns a string that contains n characters of this string, starting at the specified position index...
qreal minimumWidth() const
The minimum width the layout needs.
VerticalAlignment verticalAlignment() const
Returns the vertical alignment used for characters with this format.
QString preeditAreaText() const
Returns the text that is inserted in the layout before editing occurs.
void setWidth(qreal w)
Sets the inline object's width to w.
void setDefaultHeight(QTextEngine *eng)
void shape(int item) const
QTextCharFormat::UnderlineStyle underlineStyle
void setPosition(const QPointF &p)
Moves the text layout to point p.
void setOverline(bool overline)
Indicates that this QGlyphRun should be painted with an overline decoration if overline is true...
qreal descent() const
Returns the inline object's descent.
The QRawFont class provides access to a single physical instance of a font.
void merge(const QTextFormat &other)
Merges the other format with this format; where there are conflicts the other format takes precedence...
CursorMoveStyle
This enum describes the movement style available to text cursors.
The QFont class specifies a font used for drawing text.
qreal x() const
Returns the x-coordinate of the rectangle's left edge.
Qt::CursorMoveStyle cursorMoveStyle() const
The cursor movement style of this QTextLayout.
void setAscent(qreal a)
Sets the inline object's ascent to a.
QTextLine createLine()
Returns a new text line to be laid out if there is text to be inserted into the layout; otherwise ret...
static QString fromLatin1(const char *, int size=-1)
Returns a QString initialized with the first size characters of the Latin-1 string str...
qreal naturalTextWidth() const
Returns the width of the line that is occupied by text.
QList< FormatRange > additionalFormats() const
Returns the list of additional formats supported by the text layout.
void setTextOption(const QTextOption &option)
Sets the text option structure that controls the layout process to the given option.
QList< T > values() const
Returns a list containing all the values in the hash, in an arbitrary order.
QVariant property(int propertyId) const
Returns the property specified by the given propertyId.
void drawTextItem(const QPointF &p, const QTextItem &ti)
Draws the text item ti at position p.
QExplicitlySharedDataPointer< QFontPrivate > d
Q_DECL_CONSTEXPR const T & qBound(const T &min, const T &val, const T &max)
void setBrush(const QBrush &brush)
Sets the painter's brush to the given brush.
int size() const
Returns the number of items in the list.
void setAlpha(int alpha)
Sets the alpha of this color to alpha.
bool getSelectionBounds(QFixed *selectionX, QFixed *selectionWidth) const
int length(int item) const
void setPen(const QColor &color)
Sets the painter's pen to have style Qt::SolidLine, width 0 and the specified color.
QBrush foreground() const
Returns the brush used to render foreground details, such as text, frame outlines, and table borders.
bool boolProperty(int propertyId) const
Returns the value of the property specified by propertyId.
QFixed alignLine(const QScriptLine &line)
qreal width() const
Returns the line's width as specified by the layout() function.
QFont::HintingPreference hintingPreference
if(void) toggleToolbarShown
WrapMode wrapMode() const
Returns the text wrap mode defined by the option.
int rightCursorPosition(int oldPos) const
Returns the cursor position to the right of oldPos, next to it.
The QTextOption class provides a description of general rich text properties.
~QTextLayout()
Destructs the layout.
int formatIndex(const QScriptItem *si) const
qreal y() const
Returns the y-coordinate of this point.
bool cacheEnabled() const
Returns true if the complete layout information is cached; otherwise returns false.
void clearLayout()
Clears the line information in the layout.
static void setPenAndDrawBackground(QPainter *p, const QPen &defaultPen, const QTextCharFormat &chf, const QRectF &r)
QFixed effectiveAdvance(int item) const
bool isValid() const
Returns true if this text block is valid; otherwise returns false.
qreal top() const
Returns the y-coordinate of the rectangle's top edge.
Qt::Alignment alignment() const
Returns the text alignment defined by the option.
int length
Specifies the numer of characters the format range spans.
HB_GlyphAttributes * attributes
QTextCharFormat format
Specifies the format to apply.
void setWrapMode(WrapMode wrap)
Sets the option's text wrap mode to the given mode.
virtual void positionInlineObject(QTextInlineObject item, int posInDocument, const QTextFormat &format)
Lays out the inline object item using the given text format.
HintStyle defaultHintStyle() const
RenderHints renderHints() const
Returns a flag that specifies the rendering hints that are set for this painter.
void clearProperty(int propertyId)
Clears the value of the property given by propertyId.
void setCacheEnabled(bool enable)
Enables caching of the complete layout information if enable is true; otherwise disables layout cachi...
void setClipPath(const QPainterPath &path, Qt::ClipOperation op=Qt::ReplaceClip)
Enables clipping, and sets the clip path for the painter to the given path, with the clip operation...
qreal width() const
Returns the inline object's width.
int leftCursorPosition(int oldPos) const
Returns the cursor position to the left of oldPos, next to it.
void endLayout()
Ends the layout process.
QTextDocumentPrivate * docHandle() const
int textPosition() const
The position of the inline object within the text layout.
QRectF translated(qreal dx, qreal dy) const
Returns a copy of the rectangle that is translated dx along the x axis and dy along the y axis...
QRectF rect() const
Returns the inline object's rectangle.
bool strikeOut() const
Returns true if strikeout has been set; otherwise returns false.
bool isOutsideSelection() const
static const KeyPair *const end
int previousCursorPosition(int oldPos, CursorMode mode=SkipCharacters) const
Returns the first valid cursor position before oldPos that respects the given cursor mode...
QPen penProperty(int propertyId) const
Returns the value of the property given by propertyId; if the property isn't of QVariant::Pen type...
int xToCursor(qreal x, CursorPosition=CursorBetweenCharacters) const
Converts the x-coordinate x, to the nearest matching cursor position, depending on the cursor positio...
void setPreeditArea(int position, const QString &text)
Sets the position and text of the area in the layout that is processed before editing occurs...
QTextFormatCollection * formats() const
int size() const
Returns the number of items in the vector.
bool isNull() const
Returns true if the rectangle is a null rectangle, otherwise returns false.
bool visualCursorMovement() const
int formatIndex() const
Returns an integer describing the format of the inline object within the text layout.
The QLatin1Char class provides an 8-bit ASCII/Latin-1 character.
void draw(QPainter *p, const QPointF &point, const QTextLayout::FormatRange *selection=0) const
Draws a line on the given painter at the specified position.
qreal height() const
Returns the line's height.
QAbstractTextDocumentLayout * docLayout() const
Q_DECL_CONSTEXPR int qRound(qreal d)
virtual QFixed underlinePosition() const
void beginLayout()
Begins the layout process.
QFixed leadingSpaceWidth(const QScriptLine &line)
QFontEngine * engine(int at) const
int textStart() const
Returns the start of the line from the beginning of the string passed to the QTextLayout.
void fillRect(const QRectF &, const QBrush &)
Fills the given rectangle with the brush specified.
void setGlyphIndexes(const QVector< quint32 > &glyphIndexes)
Set the glyph indexes for this QGlyphRun object to glyphIndexes.
QPen textOutline() const
Returns the pen used to draw the outlines of characters in this format.
static qreal toReal(Register *reg, int type, bool *ok=0)
int lineCount() const
Returns the number of lines in this text layout.
virtual bool supportsSubPixelPositions() const
The QList class is a template class that provides lists.
void setRawFont(const QRawFont &rawFont)
Sets the font specified by rawFont to be the font used to look up the glyph indexes.
QRectF naturalTextRect() const
Returns the rectangle covered by the line.
QTextFormat format() const
Returns format of the inline object within the text layout.