diff --git a/src/gui/text/qtextengine.cpp b/src/gui/text/qtextengine.cpp index e2c45f9bab..45894d27b6 100644 --- a/src/gui/text/qtextengine.cpp +++ b/src/gui/text/qtextengine.cpp @@ -1206,7 +1206,6 @@ QT_BEGIN_INCLUDE_NAMESPACE QT_END_INCLUDE_NAMESPACE Q_STATIC_ASSERT(sizeof(HB_Glyph) == sizeof(glyph_t)); -Q_STATIC_ASSERT(sizeof(HB_GlyphAttributes) == sizeof(QGlyphAttributes)); Q_STATIC_ASSERT(sizeof(HB_Fixed) == sizeof(QFixed)); Q_STATIC_ASSERT(sizeof(HB_FixedPoint) == sizeof(QFixedPoint)); @@ -1272,18 +1271,23 @@ int QTextEngine::shapeTextWithHarfbuzz(const QScriptItem &si, const ushort *stri remaining_glyphs -= shaper_item.initialGlyphCount; + QVarLengthArray hbGlyphAttributes; do { if (!ensureSpace(glyph_pos + shaper_item.num_glyphs + remaining_glyphs)) return 0; + if (hbGlyphAttributes.size() < int(shaper_item.num_glyphs)) { + hbGlyphAttributes.resize(shaper_item.num_glyphs); + memset(hbGlyphAttributes.data(), 0, hbGlyphAttributes.size() * sizeof(HB_GlyphAttributes)); + } const QGlyphLayout g = availableGlyphs(&si).mid(glyph_pos); if (fontEngine->type() == QFontEngine::Multi && shaper_item.num_glyphs > shaper_item.item.length) moveGlyphData(g.mid(shaper_item.num_glyphs), g.mid(shaper_item.initialGlyphCount), remaining_glyphs); shaper_item.glyphs = reinterpret_cast(g.glyphs); - shaper_item.attributes = reinterpret_cast(g.attributes); shaper_item.advances = reinterpret_cast(g.advances); shaper_item.offsets = reinterpret_cast(g.offsets); + shaper_item.attributes = hbGlyphAttributes.data(); if (engineIdx != 0 && shaper_item.glyphIndicesPresent) { for (quint32 i = 0; i < shaper_item.initialGlyphCount; ++i) @@ -1297,6 +1301,14 @@ int QTextEngine::shapeTextWithHarfbuzz(const QScriptItem &si, const ushort *stri if (fontEngine->type() == QFontEngine::Multi) moveGlyphData(g.mid(shaper_item.num_glyphs), g.mid(shaper_item.initialGlyphCount), remaining_glyphs); + for (quint32 i = 0; i < shaper_item.num_glyphs; ++i) { + HB_GlyphAttributes hbAttrs = hbGlyphAttributes.at(i); + QGlyphAttributes &attrs = g.attributes[i]; + attrs.clusterStart = hbAttrs.clusterStart; + attrs.dontPrint = hbAttrs.dontPrint; + attrs.justification = hbAttrs.justification; + } + for (quint32 i = 0; i < shaper_item.item.length; ++i) shaper_item.log_clusters[i] += glyph_pos; diff --git a/src/gui/text/qtextengine_p.h b/src/gui/text/qtextengine_p.h index 06075eb992..342a94de66 100644 --- a/src/gui/text/qtextengine_p.h +++ b/src/gui/text/qtextengine_p.h @@ -89,21 +89,6 @@ class QAbstractTextDocumentLayout; typedef quint32 glyph_t; -#ifdef __xlC__ -typedef unsigned q_hb_bitfield; -#else -typedef quint8 q_hb_bitfield; -#endif - -struct QGlyphAttributes { - q_hb_bitfield justification :4; - q_hb_bitfield clusterStart :1; - q_hb_bitfield unused1 :1; - q_hb_bitfield unused2 :1; - q_hb_bitfield dontPrint :1; - q_hb_bitfield unused3 :8; -}; - // this uses the same coordinate system as Qt, but a different one to freetype. // * y is usually negative, and is equal to the ascent. // * negative yoff means the following stuff is drawn higher up. @@ -174,6 +159,14 @@ struct QGlyphJustification }; Q_DECLARE_TYPEINFO(QGlyphJustification, Q_PRIMITIVE_TYPE); +struct QGlyphAttributes { + uchar clusterStart : 1; + uchar dontPrint : 1; + uchar justification : 4; + uchar reserved : 2; +}; +Q_STATIC_ASSERT(sizeof(QGlyphAttributes) == 1); + struct QGlyphLayout { enum { @@ -186,7 +179,7 @@ struct QGlyphLayout glyph_t *glyphs; // 4 bytes per element QFixed *advances; // 4 bytes per element QGlyphJustification *justifications; // 4 bytes per element - QGlyphAttributes *attributes; // 2 bytes per element + QGlyphAttributes *attributes; // 1 byte per element int numGlyphs;