2006-03-05 17:24:44 +00:00
|
|
|
// -*- C++ -*-
|
|
|
|
/**
|
2006-10-03 16:17:32 +00:00
|
|
|
* \file GuiFontLoader.h
|
2006-03-05 17:24:44 +00:00
|
|
|
* This file is part of LyX, the document processor.
|
|
|
|
* Licence details can be found in the file COPYING.
|
|
|
|
*
|
|
|
|
* \author John Levon
|
|
|
|
*
|
|
|
|
* Full author contact details are available in file CREDITS.
|
|
|
|
*/
|
|
|
|
|
2006-10-03 16:17:32 +00:00
|
|
|
#ifndef QT4_FONTLOADER_H
|
|
|
|
#define QT4_FONTLOADER_H
|
|
|
|
|
|
|
|
#include "frontends/FontLoader.h"
|
2006-03-05 17:24:44 +00:00
|
|
|
|
2006-10-07 16:15:06 +00:00
|
|
|
#include "GuiFontMetrics.h"
|
|
|
|
|
2006-03-05 17:24:44 +00:00
|
|
|
#include "encoding.h"
|
|
|
|
#include "lyxfont.h"
|
|
|
|
|
|
|
|
#include <QFont>
|
|
|
|
|
2006-10-03 16:17:32 +00:00
|
|
|
namespace lyx {
|
|
|
|
namespace frontend {
|
|
|
|
|
2006-03-05 17:24:44 +00:00
|
|
|
/**
|
|
|
|
* Qt font loader for LyX. Matches LyXFonts against
|
|
|
|
* actual QFont instances, and also caches metrics.
|
|
|
|
*/
|
|
|
|
class QLFontInfo {
|
|
|
|
public:
|
|
|
|
QLFontInfo(LyXFont const & f);
|
|
|
|
|
|
|
|
/// The font instance
|
|
|
|
QFont font;
|
|
|
|
/// Metrics on the font
|
2006-10-07 16:15:06 +00:00
|
|
|
boost::scoped_ptr<GuiFontMetrics> metrics;
|
2006-03-05 17:24:44 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
/// Hold info about a particular font
|
2006-10-03 16:17:32 +00:00
|
|
|
class GuiFontLoader: public FontLoader
|
|
|
|
{
|
2006-03-05 17:24:44 +00:00
|
|
|
public:
|
|
|
|
///
|
2006-10-03 16:17:32 +00:00
|
|
|
GuiFontLoader();
|
2006-05-20 08:21:58 +00:00
|
|
|
|
|
|
|
/// Destructor
|
2006-10-03 16:17:32 +00:00
|
|
|
virtual ~GuiFontLoader();
|
2006-03-05 17:24:44 +00:00
|
|
|
|
2006-10-03 16:17:32 +00:00
|
|
|
virtual void update();
|
|
|
|
virtual bool available(LyXFont const & f);
|
2006-10-07 16:15:06 +00:00
|
|
|
inline virtual FontMetrics const & metrics(LyXFont const & f) {
|
|
|
|
return *fontinfo(f).metrics.get();
|
|
|
|
}
|
2006-03-05 17:24:44 +00:00
|
|
|
|
|
|
|
/// Get the QFont for this LyXFont
|
|
|
|
QFont const & get(LyXFont const & f) {
|
|
|
|
return fontinfo(f).font;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2006-04-05 23:56:29 +00:00
|
|
|
/// Get font info (font + metrics) for the given LyX font.
|
2006-03-05 17:24:44 +00:00
|
|
|
QLFontInfo & fontinfo(LyXFont const & f) {
|
2006-05-25 10:02:01 +00:00
|
|
|
// fi is a reference to the pointer type (QLFontInfo *) in the
|
|
|
|
// fontinfo_ table.
|
|
|
|
QLFontInfo * & fi =
|
2006-03-05 17:24:44 +00:00
|
|
|
fontinfo_[f.family()][f.series()][f.realShape()][f.size()];
|
2006-05-25 10:02:01 +00:00
|
|
|
if (!fi)
|
2006-03-05 17:24:44 +00:00
|
|
|
fi = new QLFontInfo(f);
|
|
|
|
return *fi;
|
|
|
|
}
|
|
|
|
|
|
|
|
private:
|
|
|
|
/// BUTT ugly !
|
|
|
|
QLFontInfo * fontinfo_[LyXFont::NUM_FAMILIES][2][4][10];
|
|
|
|
};
|
|
|
|
|
2006-10-03 16:17:32 +00:00
|
|
|
|
|
|
|
} // namespace frontend
|
|
|
|
} // namespace lyx
|
|
|
|
|
|
|
|
#endif // QT4_FONTLOADER_H
|