Back to index

scribus-ng  1.3.4.dfsg+svn20071115
scfonts.h
Go to the documentation of this file.
00001 /*
00002 For general Scribus (>=1.3.2) copyright and licensing information please refer
00003 to the COPYING file provided with the program. Following this notice may exist
00004 a copyright and/or license notice that predates the release of Scribus 1.3.2
00005 for which a new license (GPL+exception) is in place.
00006 */
00007 #ifndef SCFONTS_H
00008 #define SCFONTS_H
00009 
00010 #include <qstring.h>
00011 #include <qstrlist.h>
00012 #include <qstringlist.h>
00013 #include <qdict.h>
00014 //#include <qvector.h>
00015 #include <qfont.h>
00016 #include <qmap.h>
00017 #include <qdatetime.h>
00018 #include <ft2build.h>
00019 #include FT_FREETYPE_H
00020 #include FT_OUTLINE_H
00021 #include FT_GLYPH_H
00022 
00023 
00024 FT_Error ftIOFunc( FT_Stream fts, unsigned long offset, unsigned char* buffer, unsigned long count);
00025 
00026 // #include <qpixmap.h>
00027 
00028 #include "scribusapi.h"
00029 #include "fpointarray.h"
00030 #include "scconfig.h"
00031 
00032 #include "fonts/scface.h"
00033 
00034 class ScribusDoc;
00035 
00044 class SCRIBUS_API SCFonts : public QMap<QString,ScFace>
00045 {
00046        public:
00047               SCFonts();
00048               ~SCFonts();
00049               void updateFontMap();
00050               void GetFonts(QString pf, bool showFontInfo=false);
00051               void AddScalableFonts(const QString& path, QString DocName = "");
00053               const ScFace& findFont(const QString& fontName, ScribusDoc* doc = NULL);
00055               QMap<QString,QString> getSubstitutions(const QValueList<QString> skip = QValueList<QString>()) const;
00057               void setSubstitutions(const QMap<QString,QString>& substitutes, ScribusDoc* doc = NULL);
00058               void removeFont(QString name);
00060               QMap<QString, QStringList> fontMap;
00061        private:
00062               void ReadCacheList(QString pf);
00063               void WriteCacheList(QString pf);
00064               void AddPath(QString p);
00065               bool AddScalableFont(QString filename, FT_Library &library, QString DocName);
00066               void AddUserPath(QString pf);
00067 #ifdef HAVE_FONTCONFIG
00068               void AddFontconfigFonts();
00069 #else
00070 #ifndef QT_MAC
00071               void AddXFontServerPath();
00072               void AddXFontPath();
00073 #endif
00074 #endif
00075               QStrList FontPath;
00076               QString ExtraPath;
00077               struct testCache
00078               {
00079                      bool isOK;
00080                      bool isChecked;
00081                      QDateTime lastMod;
00082               };
00083               QMap<QString, testCache> checkedFonts;
00084        protected:
00085               bool showFontInformation;
00086 };
00087 
00088 struct SCFontsIterator
00089 {
00090        SCFontsIterator(SCFonts& fonts): it(fonts.begin()), end_it(fonts.end()) 
00091        {}
00092        ScFace& current()          { return *it; }
00093        QString currentKey() const { return it.key(); }
00094        bool hasNext()       const { return it != end_it; }
00095        ScFace& next()             { ++it; return current(); }
00096 
00097 private:
00098        QMap<QString,ScFace>::Iterator it, end_it;
00099 };
00100 
00101 #endif