summaryrefslogtreecommitdiffstats
path: root/src/gui/text/qtextengine_p.h
diff options
context:
space:
mode:
Diffstat (limited to 'src/gui/text/qtextengine_p.h')
-rw-r--r--src/gui/text/qtextengine_p.h60
1 files changed, 43 insertions, 17 deletions
diff --git a/src/gui/text/qtextengine_p.h b/src/gui/text/qtextengine_p.h
index 93e92e7ca8..ec7f7407b2 100644
--- a/src/gui/text/qtextengine_p.h
+++ b/src/gui/text/qtextengine_p.h
@@ -71,8 +71,6 @@
#include "private/qtextdocument_p.h"
#endif
-#include "private/qharfbuzz_copy_p.h"
-
#include "private/qfixed_p.h"
#include <private/qunicodetools_p.h>
@@ -89,6 +87,22 @@ class QPainter;
class QAbstractTextDocumentLayout;
+typedef quint32 glyph_t;
+
+#ifdef __xlC__
+typedef unsigned q_hb_bitfield;
+#else
+typedef quint8 q_hb_bitfield;
+#endif
+
+typedef struct {
+ q_hb_bitfield justification :4; /* Justification class */
+ q_hb_bitfield clusterStart :1; /* First glyph of representation of cluster */
+ q_hb_bitfield mark :1; /* needs to be positioned around base char */
+ q_hb_bitfield zeroWidth :1; /* ZWJ, ZWNJ etc, with no width */
+ q_hb_bitfield dontPrint :1;
+ q_hb_bitfield combiningClass :8;
+} QGlyphAttributes;
// this uses the same coordinate system as Qt, but a different one to freetype.
// * y is usually negative, and is equal to the ascent.
@@ -164,20 +178,20 @@ struct QGlyphLayoutInstance
{
QFixedPoint offset;
QFixedPoint advance;
- HB_Glyph glyph;
+ glyph_t glyph;
QGlyphJustification justification;
- HB_GlyphAttributes attributes;
+ QGlyphAttributes attributes;
};
struct QGlyphLayout
{
// init to 0 not needed, done when shaping
QFixedPoint *offsets; // 8 bytes per element
- HB_Glyph *glyphs; // 4 bytes per element
+ glyph_t *glyphs; // 4 bytes per element
QFixed *advances_x; // 4 bytes per element
QFixed *advances_y; // 4 bytes per element
QGlyphJustification *justifications; // 4 bytes per element
- HB_GlyphAttributes *attributes; // 2 bytes per element
+ QGlyphAttributes *attributes; // 2 bytes per element
int numGlyphs;
@@ -186,16 +200,16 @@ struct QGlyphLayout
inline explicit QGlyphLayout(char *address, int totalGlyphs)
{
offsets = reinterpret_cast<QFixedPoint *>(address);
- int offset = totalGlyphs * sizeof(HB_FixedPoint);
- glyphs = reinterpret_cast<HB_Glyph *>(address + offset);
- offset += totalGlyphs * sizeof(HB_Glyph);
+ int offset = totalGlyphs * sizeof(QFixedPoint);
+ glyphs = reinterpret_cast<glyph_t *>(address + offset);
+ offset += totalGlyphs * sizeof(glyph_t);
advances_x = reinterpret_cast<QFixed *>(address + offset);
offset += totalGlyphs * sizeof(QFixed);
advances_y = reinterpret_cast<QFixed *>(address + offset);
offset += totalGlyphs * sizeof(QFixed);
justifications = reinterpret_cast<QGlyphJustification *>(address + offset);
offset += totalGlyphs * sizeof(QGlyphJustification);
- attributes = reinterpret_cast<HB_GlyphAttributes *>(address + offset);
+ attributes = reinterpret_cast<QGlyphAttributes *>(address + offset);
numGlyphs = totalGlyphs;
}
@@ -215,7 +229,7 @@ struct QGlyphLayout
}
static inline int spaceNeededForGlyphLayout(int totalGlyphs) {
- return totalGlyphs * (sizeof(HB_Glyph) + sizeof(HB_GlyphAttributes)
+ return totalGlyphs * (sizeof(glyph_t) + sizeof(QGlyphAttributes)
+ sizeof(QFixed) + sizeof(QFixed) + sizeof(QFixedPoint)
+ sizeof(QGlyphJustification));
}
@@ -254,11 +268,11 @@ struct QGlyphLayout
} else {
const int num = last - first;
memset(offsets + first, 0, num * sizeof(QFixedPoint));
- memset(glyphs + first, 0, num * sizeof(HB_Glyph));
+ memset(glyphs + first, 0, num * sizeof(glyph_t));
memset(advances_x + first, 0, num * sizeof(QFixed));
memset(advances_y + first, 0, num * sizeof(QFixed));
memset(justifications + first, 0, num * sizeof(QGlyphJustification));
- memset(attributes + first, 0, num * sizeof(HB_GlyphAttributes));
+ memset(attributes + first, 0, num * sizeof(QGlyphAttributes));
}
}
@@ -300,7 +314,7 @@ public:
}
private:
- void *buffer[(N * (sizeof(HB_Glyph) + sizeof(HB_GlyphAttributes)
+ void *buffer[(N * (sizeof(glyph_t) + sizeof(QGlyphAttributes)
+ sizeof(QFixed) + sizeof(QFixed) + sizeof(QFixedPoint)
+ sizeof(QGlyphJustification)))
/ sizeof(void *) + 1];
@@ -603,13 +617,23 @@ public:
ItemDecorationList strikeOutList;
ItemDecorationList overlineList;
- inline bool hasFormats() const { return (block.docHandle() || specialData); }
inline bool visualCursorMovement() const
{
return (visualMovement ||
(block.docHandle() ? block.docHandle()->defaultCursorMoveStyle == Qt::VisualMoveStyle : false));
}
+ inline int preeditAreaPosition() const { return specialData ? specialData->preeditPosition : -1; }
+ inline QString preeditAreaText() const { return specialData ? specialData->preeditText : QString(); }
+ void setPreeditArea(int position, const QString &text);
+
+ inline bool hasFormats() const { return block.docHandle() || (specialData && !specialData->addFormats.isEmpty()); }
+ QList<QTextLayout::FormatRange> additionalFormats() const;
+ void setAdditionalFormats(const QList<QTextLayout::FormatRange> &formatList);
+
+private:
+ static void init(QTextEngine *e);
+
struct SpecialData {
int preeditPosition;
QString preeditText;
@@ -621,9 +645,12 @@ public:
};
SpecialData *specialData;
+ void indexAdditionalFormats();
+ void resolveAdditionalFormats() const;
+
+public:
bool atWordSeparator(int position) const;
bool atSpace(int position) const;
- void indexAdditionalFormats();
QString elidedText(Qt::TextElideMode mode, const QFixed &width, int flags = 0, int from = 0, int count = -1) const;
@@ -661,7 +688,6 @@ private:
void shapeTextWithHarfbuzz(int item) const;
void splitItem(int item, int pos) const;
- void resolveAdditionalFormats() const;
int endOfLine(int lineNum);
int beginningOfLine(int lineNum);
int getClusterLength(unsigned short *logClusters, const QCharAttributes *attributes, int from, int to, int glyph_pos, int *start);