bool surrogate = (str[i].isHighSurrogate() && i < len-1 && str[i+1].isLowSurrogate());
uint ucs4 = surrogate ? QChar::surrogateToUcs4(str[i], str[i+1]) : str[i].unicode();
if (glyphs->glyphs[glyph_pos] == 0 && str[i].category() != QChar::Separator_Line) {
- QGlyphLayoutInstance tmp = glyphs->instance(glyph_pos);
+ QGlyphLayoutInstance tmp;
+ if (!(flags & GlyphIndicesOnly))
+ tmp = glyphs->instance(glyph_pos);
for (int x=1; x < engines.size(); ++x) {
if (engines.at(x) == 0 && !shouldLoadFontEngineForCharacter(x, ucs4))
continue;
}
// ensure we use metrics from the 1st font when we use the fallback image.
- if (!glyphs->glyphs[glyph_pos]) {
+ if (!(flags & GlyphIndicesOnly) && !glyphs->glyphs[glyph_pos])
glyphs->setInstance(glyph_pos, tmp);
- }
}
if (surrogate)
CONFIG += testcase
CONFIG += parallel_test
TARGET = tst_qfontmetrics
-QT += testlib
+QT += testlib core-private gui-private
SOURCES += tst_qfontmetrics.cpp
RESOURCES += testfont.qrc
DEFINES += QT_DISABLE_DEPRECATED_BEFORE=0
#include <qfont.h>
#include <qfontmetrics.h>
#include <qfontdatabase.h>
+#include <private/qfontengine_p.h>
#include <qstringlist.h>
#include <qlist.h>
QVERIFY(fm.inFontUcs4(0x1D7FF));
}
+ {
+ QFontEngine *engine = QFontPrivate::get(font)->engineForScript(QUnicodeTables::Common);
+ QGlyphLayout glyphs;
+ glyphs.numGlyphs = 3;
+ uint buf[3];
+ glyphs.glyphs = buf;
+
+ QString string;
+ {
+ string.append(QChar::highSurrogate(0x1D7FF));
+ string.append(QChar::lowSurrogate(0x1D7FF));
+
+ glyphs.numGlyphs = 3;
+ glyphs.glyphs[0] = 0;
+ QVERIFY(engine->stringToCMap(string.constData(), string.size(),
+ &glyphs, &glyphs.numGlyphs,
+ QFontEngine::GlyphIndicesOnly));
+ QCOMPARE(glyphs.numGlyphs, 1);
+ QCOMPARE(glyphs.glyphs[0], uint(1));
+ }
+ {
+ string.clear();
+ string.append(QChar::ObjectReplacementCharacter);
+
+ glyphs.numGlyphs = 3;
+ glyphs.glyphs[0] = 0;
+ QVERIFY(engine->stringToCMap(string.constData(), string.size(),
+ &glyphs, &glyphs.numGlyphs,
+ QFontEngine::GlyphIndicesOnly));
+ QVERIFY(glyphs.glyphs[0] != 1);
+ }
+ }
+
QFontDatabase::removeApplicationFont(id);
}