Fix crash when app font is added
Loading app fonts will clear the application font cache, but QFontPrivate::engineWithScript will try to load the font again, in Mac the font engine used here must be the one used for shaping, because subsequent sub font engines may be added to it during the shaping process (QCoreTextFontEngineMulti::stringToCMap). That is why we need to fetch the font engine directly from QTextEngine's fontEngine cache instead of QFontCache. Task-number: QTBUG-20250 Reviewed-by: Eskil (cherry picked from commit 1f90ae36cff8acf581d1624bf011fe3a55c623c0) Change-Id: Ibc0054cd7df65b65a67af4a7b15027731ba417fe Reviewed-on: http://codereview.qt.nokia.com/1630 Reviewed-by: Jiang Jiang <jiang.jiang@nokia.com> Reviewed-by: Qt Sanity Bot <qt_sanity_bot@ovi.com>bb10
parent
042cffd601
commit
1080586abc
|
|
@ -3033,6 +3033,22 @@ QStackTextEngine::QStackTextEngine(const QString &string, const QFont &f)
|
|||
QTextItemInt::QTextItemInt(const QScriptItem &si, QFont *font, const QTextCharFormat &format)
|
||||
: justified(false), underlineStyle(QTextCharFormat::NoUnderline), charFormat(format),
|
||||
num_chars(0), chars(0), logClusters(0), f(0), fontEngine(0)
|
||||
{
|
||||
f = font;
|
||||
fontEngine = f->d->engineForScript(si.analysis.script);
|
||||
Q_ASSERT(fontEngine);
|
||||
|
||||
initWithScriptItem(si);
|
||||
}
|
||||
|
||||
QTextItemInt::QTextItemInt(const QGlyphLayout &g, QFont *font, const QChar *chars_, int numChars, QFontEngine *fe, const QTextCharFormat &format)
|
||||
: flags(0), justified(false), underlineStyle(QTextCharFormat::NoUnderline), charFormat(format),
|
||||
num_chars(numChars), chars(chars_), logClusters(0), f(font), glyphs(g), fontEngine(fe)
|
||||
{
|
||||
}
|
||||
|
||||
// Fix up flags and underlineStyle with given info
|
||||
void QTextItemInt::initWithScriptItem(const QScriptItem &si)
|
||||
{
|
||||
// explicitly initialize flags so that initFontAttributes can be called
|
||||
// multiple times on the same TextItem
|
||||
|
|
@ -3041,13 +3057,10 @@ QTextItemInt::QTextItemInt(const QScriptItem &si, QFont *font, const QTextCharFo
|
|||
flags |= QTextItem::RightToLeft;
|
||||
ascent = si.ascent;
|
||||
descent = si.descent;
|
||||
f = font;
|
||||
fontEngine = f->d->engineForScript(si.analysis.script);
|
||||
Q_ASSERT(fontEngine);
|
||||
|
||||
if (format.hasProperty(QTextFormat::TextUnderlineStyle)) {
|
||||
underlineStyle = format.underlineStyle();
|
||||
} else if (format.boolProperty(QTextFormat::FontUnderline)
|
||||
if (charFormat.hasProperty(QTextFormat::TextUnderlineStyle)) {
|
||||
underlineStyle = charFormat.underlineStyle();
|
||||
} else if (charFormat.boolProperty(QTextFormat::FontUnderline)
|
||||
|| f->d->underline) {
|
||||
underlineStyle = QTextCharFormat::SingleUnderline;
|
||||
}
|
||||
|
|
@ -3056,18 +3069,12 @@ QTextItemInt::QTextItemInt(const QScriptItem &si, QFont *font, const QTextCharFo
|
|||
if (underlineStyle == QTextCharFormat::SingleUnderline)
|
||||
flags |= QTextItem::Underline;
|
||||
|
||||
if (f->d->overline || format.fontOverline())
|
||||
if (f->d->overline || charFormat.fontOverline())
|
||||
flags |= QTextItem::Overline;
|
||||
if (f->d->strikeOut || format.fontStrikeOut())
|
||||
if (f->d->strikeOut || charFormat.fontStrikeOut())
|
||||
flags |= QTextItem::StrikeOut;
|
||||
}
|
||||
|
||||
QTextItemInt::QTextItemInt(const QGlyphLayout &g, QFont *font, const QChar *chars_, int numChars, QFontEngine *fe)
|
||||
: flags(0), justified(false), underlineStyle(QTextCharFormat::NoUnderline),
|
||||
num_chars(numChars), chars(chars_), logClusters(0), f(font), glyphs(g), fontEngine(fe)
|
||||
{
|
||||
}
|
||||
|
||||
QTextItemInt QTextItemInt::midItem(QFontEngine *fontEngine, int firstGlyphIndex, int numGlyphs) const
|
||||
{
|
||||
QTextItemInt ti = *this;
|
||||
|
|
|
|||
|
|
@ -314,11 +314,13 @@ public:
|
|||
logClusters(0), f(0), fontEngine(0)
|
||||
{}
|
||||
QTextItemInt(const QScriptItem &si, QFont *font, const QTextCharFormat &format = QTextCharFormat());
|
||||
QTextItemInt(const QGlyphLayout &g, QFont *font, const QChar *chars, int numChars, QFontEngine *fe);
|
||||
QTextItemInt(const QGlyphLayout &g, QFont *font, const QChar *chars, int numChars, QFontEngine *fe,
|
||||
const QTextCharFormat &format = QTextCharFormat());
|
||||
|
||||
/// copy the structure items, adjusting the glyphs arrays to the right subarrays.
|
||||
/// the width of the returned QTextItemInt is not adjusted, for speed reasons
|
||||
QTextItemInt midItem(QFontEngine *fontEngine, int firstGlyphIndex, int numGlyphs) const;
|
||||
void initWithScriptItem(const QScriptItem &si);
|
||||
|
||||
QFixed descent;
|
||||
QFixed ascent;
|
||||
|
|
|
|||
|
|
@ -2420,13 +2420,13 @@ void QTextLine::draw(QPainter *p, const QPointF &pos, const QTextLayout::FormatR
|
|||
unsigned short *logClusters = eng->logClusters(&si);
|
||||
QGlyphLayout glyphs = eng->shapedGlyphs(&si);
|
||||
|
||||
QTextItemInt gf(si, &f, format);
|
||||
gf.glyphs = glyphs.mid(iterator.glyphsStart, iterator.glyphsEnd - iterator.glyphsStart);
|
||||
gf.chars = eng->layoutData->string.unicode() + iterator.itemStart;
|
||||
QTextItemInt gf(glyphs.mid(iterator.glyphsStart, iterator.glyphsEnd - iterator.glyphsStart),
|
||||
&f, eng->layoutData->string.unicode() + iterator.itemStart,
|
||||
iterator.itemEnd - iterator.itemStart, eng->fontEngine(si), format);
|
||||
gf.logClusters = logClusters + iterator.itemStart - si.position;
|
||||
gf.num_chars = iterator.itemEnd - iterator.itemStart;
|
||||
gf.width = iterator.itemWidth;
|
||||
gf.justified = line.justified;
|
||||
gf.initWithScriptItem(si);
|
||||
|
||||
Q_ASSERT(gf.fontEngine);
|
||||
|
||||
|
|
|
|||
Loading…
Reference in New Issue