summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorSarah Smith <sarah.j.smith@nokia.com>2009-10-20 11:53:30 +1000
committerSarah Smith <sarah.j.smith@nokia.com>2009-10-20 11:53:30 +1000
commit420be4ee3d98c093c71cc840192138da6b5e61d2 (patch)
tree9debab52db05f930d2c72095eae0953a320a2816 /src
parentdfd6221d960ec8c563a687684000c3a9c4f58079 (diff)
Fix bug QTBUG-4848
Make the shapeText function return numGlyphs properly - its not always the same as length of string. Task-number: QTBUG-4848 Reviewed-by: Rhys Weatherley
Diffstat (limited to 'src')
-rw-r--r--src/gui/text/qfontengine_mac.mm14
-rw-r--r--src/gui/text/qtextengine_mac.cpp9
2 files changed, 14 insertions, 9 deletions
diff --git a/src/gui/text/qfontengine_mac.mm b/src/gui/text/qfontengine_mac.mm
index d11083fa2e..8ce437d4df 100644
--- a/src/gui/text/qfontengine_mac.mm
+++ b/src/gui/text/qfontengine_mac.mm
@@ -830,7 +830,6 @@ static OSStatus atsuPostLayoutCallback(ATSULayoutOperationSelector selector, ATS
surrogates += (str[i].unicode() >= 0xd800 && str[i].unicode() < 0xdc00
&& str[i+1].unicode() >= 0xdc00 && str[i+1].unicode() < 0xe000);
}
- Q_ASSERT(*nfo->numGlyphs == item->length - surrogates);
#endif
for (nextCharStop = item->from; nextCharStop < item->from + item->length; ++nextCharStop)
if (item->charAttributes[nextCharStop].charStop)
@@ -856,10 +855,13 @@ static OSStatus atsuPostLayoutCallback(ATSULayoutOperationSelector selector, ATS
QFixed xAdvance = FixedToQFixed(layoutData[glyphIdx + 1].realPos - layoutData[glyphIdx].realPos);
if (glyphId != 0xffff || i == 0) {
- nfo->glyphs->glyphs[i] = (glyphId & 0x00ffffff) | (fontIdx << 24);
+ if (i < nfo->glyphs->numGlyphs)
+ {
+ nfo->glyphs->glyphs[i] = (glyphId & 0x00ffffff) | (fontIdx << 24);
- nfo->glyphs->advances_y[i] = yAdvance;
- nfo->glyphs->advances_x[i] = xAdvance;
+ nfo->glyphs->advances_y[i] = yAdvance;
+ nfo->glyphs->advances_x[i] = xAdvance;
+ }
} else {
// ATSUI gives us 0xffff as glyph id at the index in the glyph array for
// a character position that maps to a ligtature. Such a glyph id does not
@@ -1029,6 +1031,8 @@ bool QFontEngineMacMulti::stringToCMapInternal(const QChar *str, int len, QGlyph
nfo.flags = flags;
nfo.shaperItem = shaperItem;
+ int prevNumGlyphs = *nglyphs;
+
QVarLengthArray<int> mappedFonts(len);
for (int i = 0; i < len; ++i)
mappedFonts[i] = 0;
@@ -1140,6 +1144,8 @@ bool QFontEngineMacMulti::stringToCMapInternal(const QChar *str, int len, QGlyph
}
ATSUClearLayoutCache(textLayout, kATSUFromTextBeginning);
+ if (prevNumGlyphs < *nfo.numGlyphs)
+ return false;
return true;
}
diff --git a/src/gui/text/qtextengine_mac.cpp b/src/gui/text/qtextengine_mac.cpp
index 4f20094303..e101830a81 100644
--- a/src/gui/text/qtextengine_mac.cpp
+++ b/src/gui/text/qtextengine_mac.cpp
@@ -50,7 +50,6 @@ static void heuristicSetGlyphAttributes(const QChar *uc, int length, QGlyphLayou
{
// ### zeroWidth and justification are missing here!!!!!
- Q_ASSERT(num_glyphs <= length);
Q_UNUSED(num_glyphs);
// qDebug("QScriptEngine::heuristicSetGlyphAttributes, num_glyphs=%d", item->num_glyphs);
@@ -596,7 +595,7 @@ void QTextEngine::shapeTextMac(int item) const
}
while (true) {
- ensureSpace(num_glyphs);
+ ensureSpace(num_glyphs);
num_glyphs = layoutData->glyphLayout.numGlyphs - layoutData->used;
QGlyphLayout g = availableGlyphs(&si);
@@ -611,9 +610,9 @@ void QTextEngine::shapeTextMac(int item) const
log_clusters,
attributes())) {
- heuristicSetGlyphAttributes(str, len, &g, log_clusters, num_glyphs);
- break;
- }
+ heuristicSetGlyphAttributes(str, len, &g, log_clusters, num_glyphs);
+ break;
+ }
}
si.num_glyphs = num_glyphs;