Scribus
Open source desktop publishing at your fingertips
scfonts.h
1 /*
2 For general Scribus (>=1.3.2) copyright and licensing information please refer
3 to the COPYING file provided with the program. Following this notice may exist
4 a copyright and/or license notice that predates the release of Scribus 1.3.2
5 for which a new license (GPL+exception) is in place.
6 */
7 #ifndef SCFONTS_H
8 #define SCFONTS_H
9 
10 #include <QByteArray>
11 #include <QDateTime>
12 #include <QFont>
13 #include <QList>
14 #include <QMap>
15 #include <QString>
16 #include <QStringList>
17 
18 #include "fonts/scface.h"
19 #include "fpointarray.h"
20 #include "scconfig.h"
21 #include "scribusapi.h"
22 
23 /* Forward declaration so we don't have to include all of Freetype. */
24 typedef struct FT_LibraryRec_ *FT_Library;
25 
26 class ScribusDoc;
27 
36 class SCRIBUS_API SCFonts : public QMap<QString,ScFace>
37 {
38  public:
39  SCFonts();
40  ~SCFonts();
41  void updateFontMap();
42  void GetFonts(QString pf, bool showFontInfo=false);
43  ScFace LoadScalableFont(const QString &filename);
44  void AddScalableFonts(const QString& path, QString DocName = "");
46  const ScFace& findFont(const QString& fontName, ScribusDoc* doc = NULL);
48  QMap<QString,QString> getSubstitutions(const QList<QString> skip = QList<QString>()) const;
50  void setSubstitutions(const QMap<QString,QString>& substitutes, ScribusDoc* doc = NULL);
51  void removeFont(QString name);
53  QMap<QString, QStringList> fontMap;
54  private:
55  void ReadCacheList(QString pf);
56  void WriteCacheList(QString pf);
57  void AddPath(QString p);
58  bool AddScalableFont(QString filename, FT_Library &library, QString DocName);
59  void AddUserPath(QString pf);
60 #ifdef HAVE_FONTCONFIG
61  void AddFontconfigFonts();
62 #else
63 #ifndef Q_OS_MAC
64  void AddXFontServerPath();
65  void AddXFontPath();
66 #endif
67 #endif
68  QStringList FontPath;
69  QString ExtraPath;
70  struct testCache
71  {
72  bool isOK;
73  bool isChecked;
74  QDateTime lastMod;
75  };
76  QMap<QString, testCache> checkedFonts;
77  protected:
78  bool showFontInformation;
79 };
80 
82 {
83  SCFontsIterator(SCFonts& fonts): it(fonts.begin()), end_it(fonts.end())
84  {}
85  ScFace& current() { return *it; }
86  QString currentKey() const { return it.key(); }
87  bool hasNext() const { return it != end_it; }
88  ScFace& next() { ++it; return current(); }
89 
90 private:
91  QMap<QString,ScFace>::Iterator it, end_it;
92 };
93 
94 #endif
Definition: scfonts.h:81
the Document Class
Definition: scribusdoc.h:90
Base Class ScFace : This is a total rewrite of the old Foi class.
Definition: scface.h:73
QMap< QString, QStringList > fontMap
maps family name to face variants
Definition: scfonts.h:53
Main class SCFonts. Subclass of QDict. This class replaces the previous SCFonts typedef...
Definition: scfonts.h:36