mirror of
https://git.lyx.org/repos/lyx.git
synced 2024-11-23 10:18:50 +00:00
* complete fix for #5327: switch back to normal drawing code if the cache
pixmap would have non-positive width or height. git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@27091 a592a061-630c-0410-9148-cb99ea01b6c8
This commit is contained in:
parent
2a69828508
commit
d51c31ca85
@ -366,31 +366,24 @@ int GuiPainter::text(int x, int y, docstring const & s,
|
|||||||
return textwidth;
|
return textwidth;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!use_pixmap_cache_) {
|
if (use_pixmap_cache_) {
|
||||||
// don't use the pixmap cache,
|
|
||||||
// draw directly onto the painting device
|
|
||||||
setQPainterPen(computeColor(f.realColor()));
|
|
||||||
if (font() != ff)
|
|
||||||
setFont(ff);
|
|
||||||
// We need to draw the text as LTR as we use our own bidi code.
|
|
||||||
QPainter::setLayoutDirection(Qt::LeftToRight);
|
|
||||||
drawText(x, y, str);
|
|
||||||
//LYXERR(Debug::PAINTING, "draw " << string(str.toUtf8())
|
|
||||||
// << " at " << x << "," << y);
|
|
||||||
return textwidth;
|
|
||||||
}
|
|
||||||
|
|
||||||
QPixmap pm;
|
QPixmap pm;
|
||||||
QString key = generateStringSignature(str, f);
|
QString key = generateStringSignature(str, f);
|
||||||
|
|
||||||
// Warning: Left bearing is in general negative! Only the case
|
// Warning: Left bearing is in general negative! Only the case
|
||||||
// where left bearing is negative is of interest WRT the the
|
// where left bearing is negative is of interest WRT the
|
||||||
// pixmap width and the text x-position.
|
// pixmap width and the text x-position.
|
||||||
// Only the left bearing of the first character is important
|
// Only the left bearing of the first character is important
|
||||||
// as we always write from left to right, even for
|
// as we always write from left to right, even for
|
||||||
// right-to-left languages.
|
// right-to-left languages.
|
||||||
int const lb = min(fm.lbearing(s[0]), 0);
|
int const lb = min(fm.lbearing(s[0]), 0);
|
||||||
int const mA = fm.maxAscent();
|
int const mA = fm.maxAscent();
|
||||||
if (!QPixmapCache::find(key, pm)) {
|
if (QPixmapCache::find(key, pm)) {
|
||||||
|
// Draw the cached pixmap.
|
||||||
|
drawPixmap(x + lb, y - mA, pm);
|
||||||
|
return textwidth;
|
||||||
|
}
|
||||||
|
|
||||||
// Only the right bearing of the last character is
|
// Only the right bearing of the last character is
|
||||||
// important as we always write from left to right,
|
// important as we always write from left to right,
|
||||||
// even for right-to-left languages.
|
// even for right-to-left languages.
|
||||||
@ -398,11 +391,7 @@ int GuiPainter::text(int x, int y, docstring const & s,
|
|||||||
int const w = textwidth + rb - lb;
|
int const w = textwidth + rb - lb;
|
||||||
int const mD = fm.maxDescent();
|
int const mD = fm.maxDescent();
|
||||||
int const h = mA + mD;
|
int const h = mA + mD;
|
||||||
if (w <= 0 || h <= 0) {
|
if (w > 0 && h > 0) {
|
||||||
LYXERR(Debug::PAINTING, "Invalid pixmap cache image for '" << s << "' h=" << h << " w=" << w);
|
|
||||||
return textwidth;
|
|
||||||
}
|
|
||||||
|
|
||||||
pm = QPixmap(w, h);
|
pm = QPixmap(w, h);
|
||||||
pm.fill(Qt::transparent);
|
pm.fill(Qt::transparent);
|
||||||
GuiPainter p(&pm);
|
GuiPainter p(&pm);
|
||||||
@ -416,10 +405,20 @@ int GuiPainter::text(int x, int y, docstring const & s,
|
|||||||
//LYXERR(Debug::PAINTING, "h=" << h << " mA=" << mA << " mD=" << mD
|
//LYXERR(Debug::PAINTING, "h=" << h << " mA=" << mA << " mD=" << mD
|
||||||
// << " w=" << w << " lb=" << lb << " tw=" << textwidth
|
// << " w=" << w << " lb=" << lb << " tw=" << textwidth
|
||||||
// << " rb=" << rb);
|
// << " rb=" << rb);
|
||||||
|
return textwidth;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
// Draw the cached pixmap.
|
|
||||||
drawPixmap(x + lb, y - mA, pm);
|
|
||||||
|
|
||||||
|
// don't use the pixmap cache,
|
||||||
|
// draw directly onto the painting device
|
||||||
|
setQPainterPen(computeColor(f.realColor()));
|
||||||
|
if (font() != ff)
|
||||||
|
setFont(ff);
|
||||||
|
// We need to draw the text as LTR as we use our own bidi code.
|
||||||
|
QPainter::setLayoutDirection(Qt::LeftToRight);
|
||||||
|
drawText(x, y, str);
|
||||||
|
//LYXERR(Debug::PAINTING, "draw " << string(str.toUtf8())
|
||||||
|
// << " at " << x << "," << y);
|
||||||
return textwidth;
|
return textwidth;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user