mirror of
https://git.lyx.org/repos/lyx.git
synced 2024-11-08 10:51:03 +00:00
cleanup/compile fix
git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@23843 a592a061-630c-0410-9148-cb99ea01b6c8
This commit is contained in:
parent
de17493932
commit
6a64982eb5
@ -14,7 +14,7 @@
|
||||
#include "FontLoader.h"
|
||||
|
||||
#include "FontInfo.h"
|
||||
#include "GuiFontLoader.h"
|
||||
#include "GuiFontMetrics.h"
|
||||
#include "qt_helpers.h"
|
||||
|
||||
#include "LyXRC.h"
|
||||
@ -45,6 +45,21 @@ extern docstring const stateText(FontInfo const & f);
|
||||
|
||||
namespace frontend {
|
||||
|
||||
/**
|
||||
* Matches Fonts against
|
||||
* actual QFont instances, and also caches metrics.
|
||||
*/
|
||||
class GuiFontInfo
|
||||
{
|
||||
public:
|
||||
GuiFontInfo(FontInfo const & f);
|
||||
|
||||
/// The font instance
|
||||
QFont font;
|
||||
/// Metrics on the font
|
||||
GuiFontMetrics metrics;
|
||||
};
|
||||
|
||||
namespace {
|
||||
|
||||
struct SymbolFont {
|
||||
@ -193,9 +208,9 @@ QFont symbolFont(QString const & family, bool * ok)
|
||||
|
||||
// A simple setFamily() fails on Qt 2
|
||||
|
||||
QString const rawName = rawName(family);
|
||||
LYXERR(Debug::FONT, "Trying " << fromqstr(rawName) << " ... ");
|
||||
font.setRawName(rawName);
|
||||
QString const raw = rawName(family);
|
||||
LYXERR(Debug::FONT, "Trying " << fromqstr(raw) << " ... ");
|
||||
font.setRawName(raw);
|
||||
|
||||
if (isChosenFont(font, family)) {
|
||||
LYXERR(Debug::FONT, "raw version!");
|
||||
@ -377,22 +392,23 @@ bool FontLoader::available(FontInfo const & f)
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
FontMetrics const & FontLoader::metrics(FontInfo const & f)
|
||||
{
|
||||
return fontinfo(f).metrics;
|
||||
}
|
||||
|
||||
/// Get the QFont for this FontInfo
|
||||
|
||||
GuiFontMetrics const & getFontMetrics(FontInfo const & f)
|
||||
{
|
||||
return fontinfo(f).metrics;
|
||||
}
|
||||
|
||||
|
||||
QFont const & getFont(FontInfo const & f)
|
||||
{
|
||||
return fontinfo(f).font;
|
||||
}
|
||||
|
||||
/// Get the QFont for this FontInfo
|
||||
GuiFontInfo const & getFontInfo(FontInfo const & f)
|
||||
{
|
||||
return fontinfo(f);
|
||||
}
|
||||
|
||||
} // namespace frontend
|
||||
} // namespace lyx
|
||||
|
@ -12,31 +12,15 @@
|
||||
#ifndef GUI_FONTLOADER_H
|
||||
#define GUI_FONTLOADER_H
|
||||
|
||||
#include "GuiFontMetrics.h"
|
||||
|
||||
#include <QFont>
|
||||
class QFont;
|
||||
|
||||
namespace lyx {
|
||||
namespace frontend {
|
||||
|
||||
/**
|
||||
* Qt font loader for LyX. Matches Fonts against
|
||||
* actual QFont instances, and also caches metrics.
|
||||
*/
|
||||
class GuiFontInfo
|
||||
{
|
||||
public:
|
||||
GuiFontInfo(FontInfo const & f);
|
||||
class GuiFontMetrics;
|
||||
|
||||
/// The font instance
|
||||
QFont font;
|
||||
/// Metrics on the font
|
||||
GuiFontMetrics metrics;
|
||||
};
|
||||
|
||||
|
||||
// Load font
|
||||
GuiFontInfo const & getFontInfo(FontInfo const & f);
|
||||
/// Metrics on the font
|
||||
GuiFontMetrics const & getFontMetrics(FontInfo const & f);
|
||||
/// Get the QFont for this FontInfo
|
||||
QFont const & getFont(FontInfo const & f);
|
||||
|
||||
|
@ -319,7 +319,8 @@ int GuiPainter::text(int x, int y, docstring const & s,
|
||||
str = ' ' + str;
|
||||
#endif
|
||||
|
||||
GuiFontInfo const & fi = getFontInfo(f);
|
||||
QFont const & ff = getFont(f);
|
||||
GuiFontMetrics const & fm = getFontMetrics(f);
|
||||
|
||||
int textwidth;
|
||||
|
||||
@ -333,7 +334,7 @@ int GuiPainter::text(int x, int y, docstring const & s,
|
||||
// Here we use the font width cache instead of
|
||||
// textwidth = fontMetrics().width(str);
|
||||
// because the above is awfully expensive on MacOSX
|
||||
textwidth = fi.metrics.width(s);
|
||||
textwidth = fm.width(s);
|
||||
if (f.underbar() == FONT_ON)
|
||||
underline(f, x, y, textwidth);
|
||||
|
||||
@ -347,7 +348,7 @@ int GuiPainter::text(int x, int y, docstring const & s,
|
||||
if (s.size() == 1 && str[0].unicode() == 0x00ad) {
|
||||
setQPainterPen(computeColor(f.realColor()));
|
||||
QTextLayout adsymbol(str);
|
||||
adsymbol.setFont(fi.font);
|
||||
adsymbol.setFont(ff);
|
||||
adsymbol.beginLayout();
|
||||
QTextLine line = adsymbol.createLine();
|
||||
line.setNumColumns(1);
|
||||
@ -361,8 +362,8 @@ int GuiPainter::text(int x, int y, docstring const & s,
|
||||
// don't use the pixmap cache,
|
||||
// draw directly onto the painting device
|
||||
setQPainterPen(computeColor(f.realColor()));
|
||||
if (font() != fi.font)
|
||||
setFont(fi.font);
|
||||
if (font() != ff)
|
||||
setFont(ff);
|
||||
// We need to draw the text as LTR as we use our own bidi code.
|
||||
setLayoutDirection(Qt::LeftToRight);
|
||||
drawText(x, y, str);
|
||||
@ -379,22 +380,22 @@ int GuiPainter::text(int x, int y, docstring const & s,
|
||||
// Only the left bearing of the first character is important
|
||||
// as we always write from left to right, even for
|
||||
// right-to-left languages.
|
||||
int const lb = min(fi.metrics.lbearing(s[0]), 0);
|
||||
int const mA = fi.metrics.maxAscent();
|
||||
int const lb = min(fm.lbearing(s[0]), 0);
|
||||
int const mA = fm.maxAscent();
|
||||
if (!QPixmapCache::find(key, pm)) {
|
||||
// Only the right bearing of the last character is
|
||||
// important as we always write from left to right,
|
||||
// even for right-to-left languages.
|
||||
int const rb = fi.metrics.rbearing(s[s.size()-1]);
|
||||
int const rb = fm.rbearing(s[s.size()-1]);
|
||||
int const w = textwidth + rb - lb;
|
||||
int const mD = fi.metrics.maxDescent();
|
||||
int const mD = fm.maxDescent();
|
||||
int const h = mA + mD;
|
||||
pm = QPixmap(w, h);
|
||||
pm.fill(Qt::transparent);
|
||||
GuiPainter p(&pm);
|
||||
p.setQPainterPen(computeColor(f.realColor()));
|
||||
if (p.font() != fi.font)
|
||||
p.setFont(fi.font);
|
||||
if (p.font() != ff)
|
||||
p.setFont(ff);
|
||||
// We need to draw the text as LTR as we use our own bidi code.
|
||||
p.setLayoutDirection(Qt::LeftToRight);
|
||||
p.drawText(-lb, mA, str);
|
||||
|
Loading…
Reference in New Issue
Block a user