42 #ifndef QTEXTENGINE_P_H 43 #define QTEXTENGINE_P_H 56 #include "QtCore/qglobal.h" 57 #include "QtCore/qstring.h" 58 #include "QtCore/qvarlengtharray.h" 59 #include "QtCore/qnamespace.h" 60 #include "QtGui/qtextlayout.h" 61 #include "private/qtextformat_p.h" 62 #include "private/qfont_p.h" 63 #include "QtCore/qvector.h" 64 #include "QtGui/qpaintengine.h" 65 #include "QtGui/qtextobject.h" 66 #include "QtGui/qtextoption.h" 67 #include "QtGui/qtextcursor.h" 68 #include "QtCore/qset.h" 69 #include "QtCore/qdebug.h" 70 #ifndef QT_BUILD_COMPAT_LIB 71 #include "private/qtextdocument_p.h" 73 #include "private/qharfbuzz_p.h" 74 #include "private/qfixed_p.h" 97 :
x(100000),
y(100000) {}
114 inline bool isValid()
const {
return x != 100000 && y != 100000;}
125 LineOrParagraphSeparator = 4,
144 :
type(0), nKashidas(0), space_18d6(0)
184 offsets =
reinterpret_cast<QFixedPoint *
>(address);
185 int offset = totalGlyphs *
sizeof(HB_FixedPoint);
186 glyphs =
reinterpret_cast<HB_Glyph *
>(address + offset);
187 offset += totalGlyphs *
sizeof(HB_Glyph);
188 advances_x =
reinterpret_cast<QFixed *
>(address + offset);
189 offset += totalGlyphs *
sizeof(
QFixed);
190 advances_y =
reinterpret_cast<QFixed *
>(address + offset);
191 offset += totalGlyphs *
sizeof(
QFixed);
194 attributes =
reinterpret_cast<HB_GlyphAttributes *
>(address + offset);
195 numGlyphs = totalGlyphs;
214 return totalGlyphs * (
sizeof(HB_Glyph) +
sizeof(HB_GlyphAttributes)
220 {
return (advances_x[item] +
QFixed::fromFixed(justifications[item].space_18d6)) * !attributes[item].dontPrint; }
244 inline void clear(
int first = 0,
int last = -1) {
247 if (first == 0 && last == numGlyphs
248 && reinterpret_cast<char *>(offsets + numGlyphs) == reinterpret_cast<char *>(glyphs)) {
249 memset(offsets, 0, spaceNeededForGlyphLayout(numGlyphs));
251 const int num = last - first;
252 memset(offsets + first, 0, num *
sizeof(
QFixedPoint));
253 memset(glyphs + first, 0, num *
sizeof(HB_Glyph));
254 memset(advances_x + first, 0, num *
sizeof(
QFixed));
255 memset(advances_y + first, 0, num *
sizeof(
QFixed));
257 memset(attributes + first, 0, num *
sizeof(HB_GlyphAttributes));
262 return reinterpret_cast<char *
>(offsets);
265 void grow(
char *address,
int totalGlyphs);
274 : Array(spaceNeededForGlyphLayout(totalGlyphs) / sizeof(void *) + 1)
277 memset(
Array::data(), 0, Array::size() *
sizeof(
void *));
282 Array::resize(spaceNeededForGlyphLayout(totalGlyphs) /
sizeof(
void *) + 1);
285 memset(
Array::data(), 0, Array::size() *
sizeof(
void *));
295 memset(buffer, 0,
sizeof(buffer));
299 void *buffer[(N * (
sizeof(HB_Glyph) +
sizeof(HB_GlyphAttributes)
302 /
sizeof(
void *) + 1];
311 : justified(false), underlineStyle(
QTextCharFormat::NoUnderline), num_chars(0), chars(0),
312 logClusters(0), f(0), fontEngine(0)
342 return uc >= 0x200b && uc <= 0x206f
344 || (uc >= 0x2028 && uc <= 0x202f )
352 num_glyphs(0), descent(-1), ascent(-1), leading(-1),
width(-1),
353 glyph_data_offset(0) {}
356 num_glyphs(0), descent(-1), ascent(-1), leading(-1),
width(-1),
357 glyph_data_offset(0) {}
379 : from(0), trailingSpaces(0), length(0),
380 justified(0), gridfitted(0),
381 hasTrailingSpaces(0), leadingIncluded(0) {}
444 bool reallocate(
int totalGlyphs);
459 DesignMetrics = 0x0002,
460 GlyphIndicesOnly = 0x0004
465 void clearLineData();
467 void validate()
const;
468 void itemize()
const;
470 bool isRightToLeft()
const;
471 static void bidiReorder(
int numRuns,
const quint8 *levels,
int *visualOrder);
473 const HB_CharAttributes *attributes()
const;
475 void shape(
int item)
const;
488 return (item < layoutData->items.size() ? layoutData->items[item].position : layoutData->string.length()) - from;
492 if (si + 1 < layoutData->items.constData()+ layoutData->items.size())
493 end = (si+1)->position;
495 end = layoutData->string.length();
512 {
return layoutData->logClustersPtr+si->
position; }
534 if (layoutData->glyphLayout.numGlyphs - layoutData->used < nGlyphs)
535 return layoutData->reallocate((((layoutData->used + nGlyphs)*3/2 + 15) >> 4) << 4);
541 int findItem(
int strPos)
const;
543 #ifdef QT_BUILD_COMPAT_LIB 546 return block.docHandle()->formatCollection();
551 #ifdef QT_BUILD_COMPAT_LIB 573 prevScaledFontEngine = 0;
603 return (visualMovement ||
616 bool atWordSeparator(
int position)
const;
617 bool atSpace(
int position)
const;
618 void indexAdditionalFormats();
627 int previousLogicalPosition(
int oldPos)
const;
628 int nextLogicalPosition(
int oldPos)
const;
629 int lineNumberForTextPosition(
int pos);
631 void insertionPointsForLine(
int lineNum,
QVector<int> &insertionPoints);
632 void resetFontEngineCache();
635 void setBoundary(
int strPos)
const;
636 void addRequiredBoundaries()
const;
637 void shapeText(
int item)
const;
638 void shapeTextWithHarfbuzz(
int item)
const;
639 #if defined(Q_WS_WINCE) 640 void shapeTextWithCE(
int item)
const;
642 #if defined(Q_WS_MAC) 643 void shapeTextMac(
int item)
const;
645 void splitItem(
int item,
int pos)
const;
647 void resolveAdditionalFormats()
const;
648 int endOfLine(
int lineNum);
649 int beginningOfLine(
int lineNum);
650 int getClusterLength(
unsigned short *logClusters,
const HB_CharAttributes *attributes,
int from,
int to,
int glyph_pos,
int *start);
655 enum { MemSize = 256*40/
sizeof(
void *) };
658 void *_memory[MemSize];
666 inline bool atEnd()
const {
return logicalItem >= nItems - 1; }
670 bool getSelectionBounds(
QFixed *selectionX,
QFixed *selectionWidth)
const;
673 return !getSelectionBounds(&tmp1, &tmp2);
709 #endif // QTEXTENGINE_P_H The QPainter class performs low-level painting on widgets and other paint devices.
QVarLengthArray< uchar > levels
The QTextLayout::FormatRange structure is used to apply extra formatting information for a specified ...
unsigned short trailingSpaces
QGlyphJustification * justifications
static QFixed fromFixed(int fixed)
The QTextCharFormat class provides formatting information for characters in a QTextDocument.
#define QT_END_NAMESPACE
This macro expands to.
void clear(int first=0, int last=-1)
bool qIsControlChar(ushort uc)
#define Q_DECLARE_FLAGS(Flags, Enum)
The Q_DECLARE_FLAGS() macro expands to.
QVarLengthArray< void * > Array
SpecialData * specialData
The QPointF class defines a point in the plane using floating point precision.
static qreal position(QGraphicsObject *item, QDeclarativeAnchorLine::AnchorLine anchorLine)
QTextDocument * document() const
Returns the text document that this layout is operating on.
bool ensureSpace(int nGlyphs) const
const unsigned short * logClusters
long ASN1_INTEGER_get ASN1_INTEGER * a
unsigned short * logClusters(const QScriptItem *si) const
The QString class provides a Unicode character string.
QGlyphLayout mid(int position, int n=-1) const
QVarLengthArray< int > visualOrder
The QChar class provides a 16-bit Unicode character.
QList< QTextLayout::FormatRange > addFormats
Q_DECL_CONSTEXPR const T & qMax(const T &a, const T &b)
glyph_metrics_t(QFixed _x, QFixed _y, QFixed _width, QFixed _height, QFixed _xoff, QFixed _yoff)
QFontEngine * prevFontEngine
#define QT_BEGIN_NAMESPACE
This macro expands to.
glyph_metrics_t transformed(const QTransform &xform) const
UnderlineStyle
This enum describes the different ways drawing underlined text.
#define Q_DECLARE_OPERATORS_FOR_FLAGS(Flags)
The Q_DECLARE_OPERATORS_FOR_FLAGS() macro declares global operator|() functions for Flags...
int length(const QScriptItem *si) const
QGlyphLayout shapedGlyphs(const QScriptItem *si) const
QVector< QScriptLine > QScriptLineArray
The QTextBlock class provides a container for text fragments in a QTextDocument.
static const char * data(const QByteArray &arr)
unsigned short num_glyphs
const QTextLayout::FormatRange * selection
QGlyphLayoutInstance instance(int position) const
void operator+=(const QScriptLine &other)
static int spaceNeededForGlyphLayout(int totalGlyphs)
QGlyphLayout availableGlyphs(const QScriptItem *si) const
Q_CORE_EXPORT int QT_FASTCALL script(uint ucs4)
QScriptItem(int p, const QScriptAnalysis &a)
unsigned short * logClustersPtr
void resize(int totalGlyphs)
QGlyphJustification justification
QVector< QScriptItem > QScriptItemArray
QTextCharFormat::UnderlineStyle underlineStyle
The QFont class specifies a font used for drawing text.
QVector< int > addFormatIndices
QAbstractTextDocumentLayout * documentLayout() const
Returns the document layout for this document.
QVector< int > resolvedFormatIndices
int length(int item) const
#define Q_AUTOTEST_EXPORT
The QTextOption class provides a description of general rich text properties.
QVarLengthGlyphLayoutArray(int totalGlyphs)
Q_DECLARE_TYPEINFO(glyph_metrics_t, Q_PRIMITIVE_TYPE)
QGlyphLayout(char *address, int totalGlyphs)
QFixed effectiveAdvance(int item) const
HB_GlyphAttributes * attributes
Qt::CursorMoveStyle defaultCursorMoveStyle
HB_GlyphAttributes attributes
QTextDocumentPrivate * docHandle() const
static int grow(int size)
The QTextItem class provides all the information required to draw text in a custom paint engine...
timeval & operator+=(timeval &t1, const timeval &t2)
bool isOutsideSelection() const
QFontEngine * prevScaledFontEngine
const QTextCharFormat charFormat
static const KeyPair *const end
void setInstance(int position, const QGlyphLayoutInstance &g)
QTextFormatCollection * formats() const
bool operator==(QBool b1, bool b2)
bool visualCursorMovement() const
QAbstractTextDocumentLayout * docLayout() const
The QAbstractTextDocumentLayout class is an abstract base class used to implement custom layouts for ...