scfonts.h
Go to the documentation of this file.00001
00002
00003
00004
00005
00006
00007 #ifndef SCFONTS_H
00008 #define SCFONTS_H
00009
00010 #include <QByteArray>
00011 #include <QDateTime>
00012 #include <QFont>
00013 #include <QList>
00014 #include <QMap>
00015 #include <QString>
00016 #include <QStringList>
00017
00018 #include <ft2build.h>
00019 #include FT_FREETYPE_H
00020 #include FT_OUTLINE_H
00021 #include FT_GLYPH_H
00022
00023 FT_Error ftIOFunc( FT_Stream fts, unsigned long offset, unsigned char* buffer, unsigned long count);
00024
00025 #include "fonts/scface.h"
00026 #include "fpointarray.h"
00027 #include "scconfig.h"
00028 #include "scribusapi.h"
00029
00030
00031 class ScribusDoc;
00032
00041 class SCRIBUS_API SCFonts : public QMap<QString,ScFace>
00042 {
00043 public:
00044 SCFonts();
00045 ~SCFonts();
00046 void updateFontMap();
00047 void GetFonts(QString pf, bool showFontInfo=false);
00048 void AddScalableFonts(const QString& path, QString DocName = "");
00050 const ScFace& findFont(const QString& fontName, ScribusDoc* doc = NULL);
00052 QMap<QString,QString> getSubstitutions(const QList<QString> skip = QList<QString>()) const;
00054 void setSubstitutions(const QMap<QString,QString>& substitutes, ScribusDoc* doc = NULL);
00055 void removeFont(QString name);
00057 QMap<QString, QStringList> fontMap;
00058 private:
00059 void ReadCacheList(QString pf);
00060 void WriteCacheList(QString pf);
00061 void AddPath(QString p);
00062 bool AddScalableFont(QString filename, FT_Library &library, QString DocName);
00063 void AddUserPath(QString pf);
00064 #ifdef HAVE_FONTCONFIG
00065 void AddFontconfigFonts();
00066 #else
00067 #ifndef Q_OS_MAC
00068 void AddXFontServerPath();
00069 void AddXFontPath();
00070 #endif
00071 #endif
00072 QStringList FontPath;
00073 QString ExtraPath;
00074 struct testCache
00075 {
00076 bool isOK;
00077 bool isChecked;
00078 QDateTime lastMod;
00079 };
00080 QMap<QString, testCache> checkedFonts;
00081 protected:
00082 bool showFontInformation;
00083 };
00084
00085 struct SCFontsIterator
00086 {
00087 SCFontsIterator(SCFonts& fonts): it(fonts.begin()), end_it(fonts.end())
00088 {}
00089 ScFace& current() { return *it; }
00090 QString currentKey() const { return it.key(); }
00091 bool hasNext() const { return it != end_it; }
00092 ScFace& next() { ++it; return current(); }
00093
00094 private:
00095 QMap<QString,ScFace>::Iterator it, end_it;
00096 };
00097
00098 #endif